| Summary: | IllegalStateException when committing a reattached containment of a detached container after branch merge with XRef enabled | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Pascal Lehmann <pascal.lehmann> | ||||||||||
| Component: | cdo.core | Assignee: | Eike Stepper <stepper> | ||||||||||
| Status: | CLOSED FIXED | QA Contact: | Eike Stepper <stepper> | ||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | erwin | ||||||||||
| Version: | 4.2 | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | All | ||||||||||||
| OS: | All | ||||||||||||
| Whiteboard: | offline-01 | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Pascal Lehmann
Created attachment 179321 [details]
Testcase
1) The number of lines that you changed is smaller than 250. confirmed. 2) You are the only author of these changed lines. confirmed. 3) You apply the EPL to these changed lines. confirmed. Created attachment 179382 [details]
Proposed patch
As changeSets do not hold the reattched objects seperately, I tried rebuilding this information using the dirty and detached lists.
1) The number of lines that you changed is smaller than 250.
confirmed.
2) You are the only author of these changed lines.
confirmed.
3) You apply the EPL to these changed lines.
confirmed.
Created attachment 179438 [details]
Combined patch - for future reference
Good catch, Pascal!
Committed to HEAD Reopened. I noticed the provided patch does not solve the problem in all cases. E.g. when the re-attached object itself contains other objects which are either modified or re-attached somewhere else, one of the objects get's re-attached twice and the following transition error occurs: java.lang.IllegalStateException: Failing event PREPARE in state DIRTY for GenRefMultiContained@OID7 (data=Pair[CDOTransaction[2:1], []]) at org.eclipse.net4j.util.fsm.FiniteStateMachine.process(FiniteStateMachine.java:153) at org.eclipse.emf.internal.cdo.CDOStateMachine.prepare(CDOStateMachine.java:229) at org.eclipse.emf.internal.cdo.CDOStateMachine.attach(CDOStateMachine.java:191) at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.applyChangeSetData(CDOTransactionImpl.java:587) at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.merge(CDOTransactionImpl.java:437) Created attachment 185297 [details]
Testcase v2
Updated testcase which shows the problem.
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. CDOTransactionImpl.applyChangedObjects() had this code:
// handle reattached objects.
if (detachedObjects.containsKey(id))
{
CDOStateMachine.INSTANCE.attach(object, this);
}
That caused unpredictable problems (state could be either DIRTY or CLEAN, but never TRANSIENT). The reason is that both the attach and the reattach transitions are recursive, i.e., self-apply to contained objects. If the contained objects are in the to-be-applied merge result themselves individually then they're handled/attached multiple times, having a state at that time that depends on the order in the merge result.
The solution is to factor out the relevant code from ReattachTransition (all but the recursion) into a separate method: CDOStateMachine.internalReattach(). This method must be called directly from CDOTransactionImpl.applyChangeSet(). All tests are passing. commit ccd00426290e441a0bbfc367ee5558acdd76338d Available in R20130613-1157 (4.2) |