Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320690 - Stale references can occur if one of two commits deletes a reference target
Summary: Stale references can occur if one of two commits deletes a reference target
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: offline-xx
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-23 02:27 EDT by Erwin Betschart CLA
Modified: 2011-06-23 03:39 EDT (History)
1 user (show)

See Also:


Attachments
Testcase (3.75 KB, patch)
2010-07-23 02:31 EDT, Erwin Betschart CLA
stepper: iplog+
Details | Diff
patch for testcase Bugzilla_320690_Tests (7.49 KB, patch)
2010-08-02 10:31 EDT, Erwin Betschart CLA
stepper: iplog+
Details | Diff
Proposed fix. (4.06 KB, patch)
2010-08-02 10:34 EDT, Erwin Betschart CLA
stepper: iplog+
Details | Diff
New patch - for future reference (63.64 KB, patch)
2010-08-08 03:14 EDT, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erwin Betschart CLA 2010-07-23 02:27:46 EDT
Build Identifier: 4.0

Clone of bug 315407 (3.0)

Commit 1 adds a reference to object X.
Commit 2 detaches X.

Both can happen at the same time when the commits arrive at the server, so no
client logic can detect and prevent this scenario.

Reproducible: Always
Comment 1 Erwin Betschart CLA 2010-07-23 02:31:41 EDT
Created attachment 175040 [details]
Testcase

Testcase which shows that it is possible to lock detached target objects.

I confirm to
1) The number of lines that you changed is smaller than 250.
2) You are the only author of these changed lines.
3) You apply the EPL to these changed lines.
Comment 2 Eike Stepper CLA 2010-07-24 02:28:21 EDT
In your test case, why do you disable passive updates? Is that somehow relevant?

I think that your test logic does *not* imply any concurrency issue because the two commits happen sequentially. Tx1 first detaches the contained element and only after that commit was successful tx2 adds a cross reference to this element. Investigating why this second commit does not produce a server exception...
Comment 3 Eike Stepper CLA 2010-07-24 03:02:41 EDT
The problem was that locking in the server is generally a "transient" operation, i.e. the "thing" that is actually locked is either a CDOID or a CDOIDAndBranch, but not a CDORevision. Hence it was possible to lock detached objects. I've fixed that with an additional "persistent" existance check after all locks have been acquired.

Committed to HEAD
Comment 4 Eike Stepper CLA 2010-07-24 03:03:59 EDT
Martin, let us discuss whether this issue is alo relevant for containment cycle detection...
Comment 5 Erwin Betschart CLA 2010-07-26 03:58:21 EDT
(In reply to comment #2)
> In your test case, why do you disable passive updates? Is that somehow
> relevant?
> 
> I think that your test logic does *not* imply any concurrency issue because the
> two commits happen sequentially. Tx1 first detaches the contained element and
> only after that commit was successful tx2 adds a cross reference to this
> element. Investigating why this second commit does not produce a server
> exception...

I disabled the passive updates in order to simulate concurrent commits. The invalidation of the removal of contained_1 whould have removed the reference nonContainer_2.setElement(contained_2);
on transaction 2.
Comment 6 Eike Stepper CLA 2010-07-26 05:35:27 EDT
Interesting idea ;-)
Comment 7 Erwin Betschart CLA 2010-08-02 10:25:18 EDT
Reopening due to the following scenario:

A: container
B: referencer
C: contained in A

if C is removed from A & B the commit fails because the xRef check does not check the deltas. That is the xRef code sees that B still references C and therefore permits deleting C.

I'll attach a testcase and a fix.
Comment 8 Erwin Betschart CLA 2010-08-02 10:31:00 EDT
Created attachment 175715 [details]
patch for testcase Bugzilla_320690_Tests
Comment 9 Erwin Betschart CLA 2010-08-02 10:32:05 EDT
For attachment 175715 [details]

I confirm to
1) The number of lines that you changed is smaller than 250.
2) You are the only author of these changed lines.
3) You apply the EPL to these changed lines.
Comment 10 Erwin Betschart CLA 2010-08-02 10:34:56 EDT
Created attachment 175716 [details]
Proposed fix.

Go through the deltas and check if the found X-Ref is removed.
Comment 11 Erwin Betschart CLA 2010-08-02 10:35:33 EDT
For attachment 175716 [details]

I confirm to
1) The number of lines that you changed is smaller than 250.
2) You are the only author of these changed lines.
3) You apply the EPL to these changed lines.
Comment 12 Eike Stepper CLA 2010-08-08 03:14:39 EDT
Created attachment 176101 [details]
New patch - for future reference

Erwin, thank you for your fix. I had to change it for several reasons and I also fixed the situation that a client deletes an object and adds references to it in the same commit.
Comment 13 Eike Stepper CLA 2010-08-08 03:17:27 EDT
Committed to HEAD
Comment 14 Eike Stepper CLA 2011-06-23 03:39:30 EDT
Available in R20110608-1407