mysql duplicate key
使用0d04161b9ea1ea1793fb1a0c9c64a08103488867编译的版本,使用mysql 数据库作为tx event 存储,日志中发现下列错误
[EL Warning]: 2018-03-23 03:32:59.887--UnitOfWork(159067768)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1613' for key 'eventId' Error Code: 1062 Call: INSERT INTO Command (COMPENSATIONMETHOD, EVENTID, GLOBALTXID, INSTANCEID, LASTMODIFIED, LOCALTXID, PARENTTXID, PAYLOADS, SERVICENAME, STATUS, VERSION) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) bind => [11 parameters bound]
When multiple scanners detect the failed event and compensate at the same time, it needs to store the compensate command only once. This is why we introduce the eventId as a unique key. With this constraint, no duplicate compensate commands will be stored in db.
@eric-lee-ltk I think we need to avoid the multiple scanner handle the same compensation to resolve this kind of issue.