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

Bug 361819

Summary: Double refresh breaks model consistency
Product: [Modeling] EMF Reporter: Egidijus Vaisnora <vaisegid>
Component: cdo.coreAssignee: Egidijus Vaisnora <vaisegid>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: saulius.tvarijonas
Version: 4.1Flags: stepper: review+
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Testcase
none
Patch v1 none

Description Egidijus Vaisnora CLA 2011-10-24 11:24:49 EDT
It happens in cases, when server side contains objects with greater version by value of two or more comparing to local version. When two refresh are called on the session, first refresh brings newer revision adds to local cache and converts object to PROXY state, second updates removes newer revision from local cache.  PROXY state is resolved with a revision, found in the local cache (it is the first version revision).
Comment 1 Egidijus Vaisnora CLA 2011-10-24 11:28:01 EDT
Created attachment 205834 [details]
Testcase
Comment 2 Egidijus Vaisnora CLA 2011-10-25 02:44:08 EDT
Created attachment 205877 [details]
Patch v1
Comment 3 Egidijus Vaisnora CLA 2011-10-25 03:34:42 EDT
For this issue are collaborating two problems:

- in cache is left stale revision. When new revision is send from server on refresh, the old revision in local cache is revised, but only if old revision has version less by one value comparing to the received new one. Else old revision is not revised and lives in the cache.
- revision is removed from the local cache if it is not revised and is not "viewed" by any of sessions view before each session refresh. I do not recall why it was needed, but I remember it was one of the bugfix. Side effect of this removal is that if object is in PROXY state, it is decided to be not "viewed" and then its revision is removed from local cache. If object transit to CLEAN state before update, revision would stay in the cache.

Patch fixes first issue, which looks for me more important, because it opens gate for model inconsistency. Patch ensures, if in local cache is attempting to add revision with "revised == 0" and if it has already revision "revised == 0" in the cache, and there are no local information to correctly set revised data, then old revision is removed from cache.
Comment 4 Eike Stepper CLA 2011-11-12 03:05:36 EST
I've slightly refactored the revision manager changes. 

You tend to forget that tests must be included in AllConfigs.java. Without that you can not execute the AllTests suite which is required to prevent regressions. In this case your test fails in all legacy scenarios. Please investigate.

I've committed the review result to branch bugs/361819:

commit 349f8f60e5a248bfc486ac05c76d407bfb7aedb2
Author: Eike Stepper <stepper@esc-net.de> 2011-11-12 09:02:26
Committer: Eike Stepper <stepper@esc-net.de> 2011-11-12 09:02:26
Parent: 1f620cfdc202d0f8334fff39be7f8279e263d30f ([363287] CDODeltaNotification.getOldValue() returns a CDOIDObjectLongImpl on remotely detached CDOObject  https://bugs.eclipse.org/bugs/show_bug.cgi?id=363287)
Branches: bugs/361819

[361819] Double refresh breaks model consistency 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=361819
Comment 5 Eike Stepper CLA 2011-11-12 03:16:28 EST
Can not push the branch with EGit, waiting for Stefan to help...
Comment 6 Eike Stepper CLA 2011-11-12 11:53:59 EST
Okay, my push spec was wrong. Now I pushed the mentioned branch.
Comment 7 Eike Stepper CLA 2011-12-07 02:26:20 EST
Hi Egidijus, still interested in this? Please take a look at the mentioned branch...
Comment 8 Egidijus Vaisnora CLA 2011-12-08 02:55:51 EST
Fixed precondition checking for PROXY state existence in legacy mode. Seems that legacy is resolving PROXY earlier

commit	37b31a837b4c76bbdae1951788810bcc5bc7cda1 (patch) (side-by-side diff)
tree	ecb80baf94fe6178c44f6bbec3fd1798c070a492
parent	349f8f60e5a248bfc486ac05c76d407bfb7aedb2 (diff)
Comment 9 Eike Stepper CLA 2011-12-08 10:47:48 EST
I understand now. I added that check back and excluded the test case from legacy scenraios:  @Skips(IModelConfig.CAPABILITY_LEGACY)

commit 77284104fe836990c76ee674c5cda6c9fcd1a664
Author: Eike Stepper <stepper@esc-net.de> 2011-12-08 16:46:35
Committer: Eike Stepper <stepper@esc-net.de> 2011-12-08 16:46:35
Parent: 37b31a837b4c76bbdae1951788810bcc5bc7cda1 (Disabling PROXY state checking as condition. Legacy mode seems to resolve PROXY earlier)

[361819] Double refresh breaks model consistency 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=361819
Comment 10 Eike Stepper CLA 2011-12-08 11:52:01 EST
Something went wrong with Git, trying again: commit b9f55459d56685d2f19acf498a1eb634a3e0ad0b
Comment 11 Eike Stepper CLA 2011-12-08 12:05:19 EST
commit 084f1896ecec875265340e524ae837337ecf3ce2
Author: Eike Stepper <stepper@esc-net.de> 2011-12-08 17:53:20
Committer: Eike Stepper <stepper@esc-net.de> 2011-12-08 17:53:20
Parent: 0cf119f43e3bd6fa13f028ea32b88a67fac3e691 ([365832] Issues when trying to import changes: Cannot modify a frozen exception issue  https://bugs.eclipse.org/bugs/show_bug.cgi?id=365832)
Parent: b9f55459d56685d2f19acf498a1eb634a3e0ad0b ([361819] Double refresh breaks model consistency  https://bugs.eclipse.org/bugs/show_bug.cgi?id=361819)
Branches: origin/master, master

Merge branch 'bugs/361819'
Comment 12 Eike Stepper CLA 2011-12-08 12:18:31 EST
Backport to 4.0 via bug 366066.
Comment 13 Eike Stepper CLA 2012-09-21 07:18:10 EDT
Closing.