[CDO] Is CDOMergingConflictResolver really called back when conflicts occur ? [message #1471189] |
Wed, 12 November 2014 18:50  |
Eclipse User |
|
|
|
Hi,
I'm doing some tests with 2 CDO clients that do the same model changes : same attribute on a same object instance in a while loop :
while (true) {
company.setName("Test client[" + args[0] + "] " + UUIDGenerator.DEFAULT.generate());
System.out.println(company.getName());
try {
transaction.commit();
Thread.sleep(200);
} catch (Exception e) {
e.printStackTrace();
}
}
The model is the one defined in org.eclipse.emf.cdo.examples.company
I have registered CDOMergingConflictResolver in my transaction:
transaction.options().addConflictResolver(new CDOMergingConflictResolver());
If I put a breakpoint in CDOMergingConflictResolver.resolveConflicts(Set<CDOObject> conflicts), I failed to stop in (I'm in debug of course).
Nevertheless I got exceptions due to conflits:
org.eclipse.emf.cdo.util.CommitConflictException: Attempt by Transaction[62:1] to modify historical revision: CDORevisionDelta[Company@OID6:0v8 343 --> [CDOFeatureDelta[name, SET, value=Test client[2] _fmDrYGrFEeSXQuTOjw9uRg, oldValue=UNSPECIFIED]]]
at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:77)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commitSynced(CDOTransactionImpl.java:1237)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1206)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1198)
Hence, I do not understand why this conflict resolver is not called back to get a chance to solve them.
Does anyone have an idea ?
Stephane.
|
|
|
|
|
Re: [CDO] Is CDOMergingConflictResolver really called back when conflicts occur ? [message #1472484 is a reply to message #1471714] |
Thu, 13 November 2014 17:46   |
Eclipse User |
|
|
|
Hi Eike,
I have debugged the situation and I know why the resolvers are not called back.
In fact, conflicts are always null in CDOViewImpl after doInvalidate(...) after the call to :
Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> conflicts = invalidate(allChangedObjects, allDetachedObjects, deltas, revisionDeltas, detachedObjects);
Hence, I stepped in to try understanding why:
In this method:
When looping on allChangedObjects, one delta is created in my case for CDOObject Company OID6 (OID6 is mentioned by the CDORevisionDelta ) but when requesting CDOObject changedObject = objects.get(key.getID()); it returns null.
Indeed, in the field objects, I did not retrieve my object Company OID6.
Hence I did not enter in the if (changedObject != null) case >>> no conflict is created.
One thing is really surprising: my Company object is not in "objects" list, only some objects are there linked to the CDOResource path....
I would really appreciate if you can run the app I provided to reproduce.
By the way, I put a bug in the app if the resource is empty. You have to replace resource.getContents().get(0) by following lines:
...
List<EObject> contents = resource.getContents();
Company company = null;
if (contents.isEmpty()) {
company = CompanyFactory.eINSTANCE.createCompany();
contents.add(company);
transaction.commit();
} else {
company = (Company) contents.get(0);
}
....
Thanks for your Help,
Stéphane.
|
|
|
|
|
|
|
Re: [CDO] Is CDOMergingConflictResolver really called back when conflicts occur ? [message #1548189 is a reply to message #1548077] |
Mon, 05 January 2015 17:15  |
Eclipse User |
|
|
|
Hi There,
I cleaned the code of my simple application to make sure it is understandable by others.
Now, I can see in debugging the CDOMergingConflictResolver is called in some cases but I still have LocalCommitConflictException.
If someone can run this projet and spend some times to understand why it failed to merge the changes.
Is it due to the pace of the changes (i.e 200ms, it was to enforce the conflicts) on the same structural feature ?
Thanks in advance,
Stéphane.
|
|
|
Powered by
FUDForum. Page generated in 0.06842 seconds