Community
Participate
Working Groups
Build Identifier: I get a strange MySQL error when merging branches (see attached log). MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'cdo_objects_idx0' Reproducible: Always Steps to Reproduce: 1. Create multiple branches that are branched of the MAIN branch at create time: CDOBranch mainBranch = ...; long timestamp = mainBranch.getBase().getTimeStamp(); CDOBranch result = mainBranch.createBranch(branchName, timestamp); 2. Create some object tree on one branch and commit. 3. Try to merge this branch to another (which at that time should be empty). CDOTransaction transaction = session.openTransaction(targetBranch); CDOMerger merger = new DefaultCDOMerger.PerFeature.ManyValued(); transaction.merge(sourceBranch.getHead(), merger); transaction.commit();
Created attachment 188453 [details] console log showing the error
As discussed with Stefan Winkler I refer to Bug 336382. > Hi Lothar, > > please open a Bug and refer to the test case attached to Bug 336382. > This test case fails w/ range-based branching on a MySQL database.
Created attachment 188838 [details] patch-v1 We ignore the exception by checking for the respective SQL state. Unfortunately, this code is returned differently by MySQL. To handle this, I moved the decision whether we have a duplicate key constraint violation into the DBAdapter. The patch Found it. The duplicate key exception is a known error which occurs when new objects from another branch are added to a target branch. For H2, we ignore the exception by checking for the respective SQL status code. Unfortunately, this code is returned differently by MySQL. To handle this, I moved the decision whether we have a duplicate key constraint violation into the DBAdapter. The patch also contains the testcase mentioned above. Tested with mysql and H2.
Created attachment 189468 [details] Patch v2 - ready to be committed
Stefan, please go ahead...
Committed to trunk, rev. 7308
When I successfully branch a model using this change, I still see a similar constraint violation in HorizontalBranchClassMapping when I subsequently try to commit certain changes in the source branch (the one I branched from). An example stack trace is below. I believe a similar change is required in HorizontalBranchClassMapping to what was done in ObjectTypeTable. org.eclipse.emf.cdo.util.CommitException: Rollback in DBStore: org.eclipse.net4j.db.DBException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '18581-3-1' for key 'PrimaryContract_idx0' at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeValues(HorizontalBranchingClassMapping.java:653) at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping$FeatureDeltaWriter.process(HorizontalBranchingClassMapping.java:129) at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeRevisionDelta(HorizontalBranchingClassMapping.java:1074) at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevisionDelta(DBStoreAccessor.java:542) at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevisionDeltas(DBStoreAccessor.java:527) at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:95) at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:135) at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:409) at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:40) at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1) at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96) at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:244) at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:92) at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109) at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84) at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90) at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326) at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63) at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63) at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251) at org.eclipse.net4j.signal.Signal.run(Signal.java:147) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '18581-3-1' for key 'PrimaryContract_idx0' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2046) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1964) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1949) at org.eclipse.net4j.db.DBUtil.update(DBUtil.java:558) at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeValues(HorizontalBranchingClassMapping.java:647) ... 23 more at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:94) at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1056) at org.eclipse.emf.cdo.transaction.CDOPushTransaction.push(CDOPushTransaction.java:239) at biz.tradescape.mmt.ui.editor.AbstractCDOEditor$6.run(AbstractCDOEditor.java:693) at biz.tradescape.compatibility.JobFactoryImpl$2$1.run(JobFactoryImpl.java:41) at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) at biz.tradescape.compatibility.JobFactoryImpl$2.run(JobFactoryImpl.java:45) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Reopening for Cameron.
Created attachment 190721 [details] Example fix in the MySQL case This appear so to fix the issue in a MySQL specific. I'm not sure about the more generalized solution.
Moving all open bug reports to 4.1 because the release is very near and it's hghly unlikely that there will be spare time to address 4.0 problems. Please make sure that your patches can be applied against the master branch and that your problem is not already fixed there!!!
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
We'll try to address open problems in 4.3 (master) first and then port fixes back to 4.2.
Moving all open bugzillas to 4.5.
Moving all unaddressed bugzillas to 4.6.
Moving all open bugs to 4.7
Moving all unresolved issues to version 4.8-
Moving all unresolved issues to version 4.9
I assume that this is fixed now with the changes of bug 546872.
Closing.