Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326518

Summary: List index problem during merge can cause a StaleReference in database even with XRef checking enabled.
Product: [Modeling] EMF Reporter: Pascal Lehmann <pascal.lehmann>
Component: cdo.coreAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: cyril.jaquier
Version: 4.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Testcase
stepper: iplog+
Proposed patch to fix the index problem
stepper: iplog+
Combined patch - for future reference none

Description Pascal Lehmann CLA 2010-09-29 07:31:30 EDT
Build Identifier: 4.0

With the current implementation of WithIndex.adjustAfterRemoval, list indices are not correctly 'patched' when merging using the CDODefaultMerger.ManyValued merger.

Normally, the XRef check on the server should prevent committing this, but when the indices for an ADD and REMOVE feature delta on the same list have the same index (wrongly patched), the deltas are optimized away and the changeSet contains the detached object from the REMOVE without the associated list change, which then leads to the stale reference on the server.

Reproducible: Always

Steps to Reproduce:
See testcase
Comment 1 Pascal Lehmann CLA 2010-09-29 07:35:01 EDT
Created attachment 179833 [details]
Testcase

Testcase which will throw an ObjectNotFoundException when accessing the list after commit.
Comment 2 Pascal Lehmann CLA 2010-09-29 07:42:31 EDT
Created attachment 179834 [details]
Proposed patch to fix the index problem

This patch addresses the index problem. However, it might be possible to create the situation as described in the testcase in some other way, which might create the need for more stale reference checking on the server.

NOTE: the ManyValued merger does not yet work correctly for larger lists, I might post an improved version when I finally find some time to clean up my code :)

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.
Comment 3 Eike Stepper CLA 2010-10-01 02:24:57 EDT
Created attachment 180011 [details]
Combined patch - for future reference

Plus AllConfigs.java
Comment 4 Eike Stepper CLA 2010-10-01 03:09:29 EDT
Committed to HEAD
Comment 5 Eike Stepper CLA 2010-10-01 03:10:57 EDT
Committed to HEAD
Comment 6 Eike Stepper CLA 2011-06-23 03:39:23 EDT
Available in R20110608-1407