Community
Participate
Working Groups
Build Identifier: I20110613-1736 + When we try to create multiple resources concurrently we get an exception that seems directly related to the store we use. + We use a tree locking strategy to avoid conflicts happening at the resource creation level. + I have been able to reproduce this exception outside of our environement using cdo testing framework in the unit test provided. + The issue seem to be somehow related to timing + Issue was tested with Mysql Store and Hsql Db Store and should be reproducible with both (exception differs slightly but seem to refer to the same problem) Reproducible: Always Steps to Reproduce: 1. Run the unit test with a Mysql or HsqlDb store 2. You should see the exception appear in the console -> For Mysql : [ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'http://www.eclipse.org/emf/CDO/tests/model1/1.0.0' for key 'cdo_package_units_idx0' org.eclipse.net4j.db.DBException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'http://www.eclipse.org/emf/CDO/tests/model1/1.0.0' for key 'cdo_package_units_idx0' at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:263) at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:292) at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.writePackageUnits(MetaDataManager.java:138) at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writePackageUnits(DBStoreAccessor.java:819) at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:76) at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149) at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:425) at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:42) 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.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679) ->For HSQLDB : [ERROR] java.sql.SQLException: Violation of unique index CDO_PACKAGE_UNITS_IDX0: duplicate value(s) for column(s) ID in statement [INSERT INTO cdo_package_units VALUES (?, ?, ?, ?)] org.eclipse.net4j.db.DBException: java.sql.SQLException: Violation of unique index CDO_PACKAGE_UNITS_IDX0: duplicate value(s) for column(s) ID in statement [INSERT INTO cdo_package_units VALUES (?, ?, ?, ?)] at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:263) at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:292) at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.writePackageUnits(MetaDataManager.java:138) at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writePackageUnits(DBStoreAccessor.java:819) at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:76) at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149) at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:425) at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:42) 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.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679)
Created attachment 200465 [details] Test case to reproduce the error Test Case to reproduce the issue
We'll analyze this in 4.1 first and then eventually port thr fix to maintenance. Stefan, is this issue a result of *some* SQL DBs not properly executing DDL in the transaction context? Abdel, starting with CDO 4.0 you can nicely work around this issue by using the new method IRepository.setInitialPackages(EPackage...), which must be called *before te repository is started for the first time* .
(In reply to comment #2) > Stefan, is this issue a result of *some* SQL DBs not properly executing DDL in > the transaction context? Maybe. I cannot say for sure. Another possibility could be that the server does not notice that it receives the same package multiple times and it regards the same package as new in two different threads. But I assume this mechanism is generally thread safe?
(In reply to comment #3) > Another possibility could be that the server does not notice that it receives > the same package multiple times and it regards the same package as new in two > different threads. > But I assume this mechanism is generally thread safe? That does ring a bell. I think we don't lock meta instances at all! Probably because they are always immutable and I did not consider that two commits with any new packages should compete for exclusive package registry access. Assigning to myself...
Created attachment 200797 [details] Test case as patch (easier to apply) BTW. the test case does pass for me.
(In reply to comment #5) > Created attachment 200797 [details] > Test case as patch (easier to apply) > > BTW. the test case does pass for me. The test does pass but produces an exception, reproducing the exception was the objective behind the test, I just wanted to provide some fast way to reproduce this in CDO environment without going trough all the configuration needed for a CDO store, so I used the testing framework. Just to make sure, I've just re-run this test on a different machine and the error was still reproducible.
Created attachment 200873 [details] Fix
Created attachment 200874 [details] Fix v2
Committed revision 8856: - trunk/plugins/org.eclipse.emf.cdo.common - trunk/plugins/org.eclipse.emf.cdo.server - trunk/plugins/org.eclipse.emf.cdo.tests
Resolved. Tested in PackageRegistryTest.testConcurrentPackageRegistration2()
Closing.