servicecomb-pack icon indicating copy to clipboard operation
servicecomb-pack copied to clipboard

mysql duplicate key

Open cmonkey opened this issue 7 years ago • 2 comments

使用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]

cmonkey avatar Mar 23 '18 03:03 cmonkey

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 avatar Mar 23 '18 06:03 eric-lee-ltk

@eric-lee-ltk I think we need to avoid the multiple scanner handle the same compensation to resolve this kind of issue.

WillemJiang avatar Mar 24 '18 08:03 WillemJiang