Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CDO understanding commit conflicts
CDO understanding commit conflicts [message #1832743] Thu, 24 September 2020 09:53 Go to next message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 109
Registered: July 2015
Senior Member
The code below will create a LocalCommitConflictException on the commit for trans2.
I would like to understand why this is.

The resource for path2 is not touched anymore by trans1 after the initial commit.
I think this is something specific to resource deletions? If I simply change the content of path2 then everything seems to be fine.

        CDOTransaction trans = cdoSession.openTransaction();
        CDOTransaction trans2 = cdoSession.openTransaction();
        try {
            String path1 = "/path1";
            String path2 = "/path2";
            final CDOResource res = trans.createResource(path1);
            trans.commit();
            res.setPath(path2);
            trans.commit();
            trans2.getResource(path2).delete(null);
            trans.createResource("/someotherpath");
            trans.commit();
            trans2.commit(); // <<<<<<<<<< commit conflict here
        } finally {
            trans.close();
            trans2.close();
        }
;
Re: CDO understanding commit conflicts [message #1832788 is a reply to message #1832743] Fri, 25 September 2020 04:48 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6557
Registered: July 2009
Senior Member
I factored your snippet into an executable CDO test case:

  @CleanRepositoriesBefore(reason = "Root resource access")
  @CleanRepositoriesAfter(reason = "Root resource access")
  public void testCommitConflict() throws Exception
  {
    CDOSession session = openSession();
    CDOTransaction trans1 = session.openTransaction();
    CDOTransaction trans2 = session.openTransaction();

    String path1 = "/path1";
    String path2 = "/path2";
    CDOResource res1 = trans1.createResource(path1);
    trans1.commit();

    res1.setPath(path2);
    CDOCommitInfo commitInfoA = trans1.commit();

    trans2.waitForUpdate(commitInfoA.getTimeStamp());
    trans2.getResource(path2).delete(null);

    trans1.createResource("/someotherpath");
    CDOCommitInfo commitInfoB = trans1.commit();

    trans2.waitForUpdate(commitInfoB.getTimeStamp());

    if (trans2.hasConflict())
    {
      fail("Conflicts: " + trans2.getConflicts());
    }

    trans2.commit();
  }


It outputs the following:

Conflicts: CDOResource@OID1[CONFLICT]("/")


Both the addition and the deletion of a top-level resource create a change delta for the root resource "/". Depending on what transaction commits this change delta first this creates a conflict in the other transaction.

Note also that I added some waitForUpdate() calls. The commit() calls are executed completely sequentially and synchronously in one thread, but the resulting invalidations in the other views/transactions happen in background threads. The CDOView.waitForUpdate() method waits until all updates (i.e., invalidations) until the given time stamp are received by that view/transaction. Your code would cause a CommitConflictException in any case, but without the predictable timing via waitForUpdate() you can't be sure where the conflict is detected (on the server or already on the client).


Re: CDO understanding commit conflicts [message #1832791 is a reply to message #1832788] Fri, 25 September 2020 08:20 Go to previous message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 109
Registered: July 2015
Senior Member
Thanks Eike, now it's clear to me!
Previous Topic:Xcore editor not loaded anymore
Next Topic:[CDO] harmless runtime exception during osgi shutdown
Goto Forum:
  


Current Time: Wed Apr 21 21:20:46 GMT 2021

Powered by FUDForum. Page generated in 0.01564 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top