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

Bug 437005

Summary: Out-of-date .snap file prevents Eclipse from running
Product: [Eclipse Project] Platform Reporter: Sergey Prigogin <eclipse.sprigogin>
Component: ResourcesAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: daniel_megert, david_williams, el_gaseron, john.arthorne, sptaszkiewicz
Version: 4.4   
Target Milestone: 4.4.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The error log none

Description Sergey Prigogin CLA 2014-06-09 18:44:09 EDT
Created attachment 244100 [details]
The error log

Eclipse 4.4 Build id: I20140528-2000

A dialog pops up saying: "An error has occurred. See the log file
/home/sprigogin/workspace/.metadata/.log."

This bug is similar to bug 149121, although in Eclipse 4.3.2 on the same workspace the displayed dialog is blank.
Comment 1 Szymon Ptaszkiewicz CLA 2014-06-10 09:03:00 EDT
Can you please attach the affected workspace?
Comment 2 Sergey Prigogin CLA 2014-06-10 10:29:31 EDT
(In reply to Szymon Ptaszkiewicz from comment #1)
> Can you please attach the affected workspace?

I cannot attach the affected workspace since it contains proprietary information. I'll work on a fix myself when I have time.
Comment 3 Sergey Prigogin CLA 2014-06-20 21:29:59 EDT
The problem was caused by a leftover .snap file that was older than the tree:

/home/sprigogin/workspaces/bug_437005/.metadata/.plugins/org.eclipse.core.resources:
total 48
drwxr-x---   6 sprigogin eng  4096 Jun  9 15:20 .
drwxr-x---  55 sprigogin eng  4096 May 22 15:59 ..
drwxr-x--- 258 sprigogin eng  4096 Apr 24 14:44 .history
drwxr-x---  20 sprigogin eng  4096 May 30 16:50 .projects
drwxr-x---   3 sprigogin eng  4096 Jun  9 15:10 .root
drwxr-x---   2 sprigogin eng  4096 Jun  9 15:10 .safetable
-rw-r-----   1 sprigogin eng 24570 Jun  6 04:49 .snap

/home/sprigogin/workspaces/bug_437005/.metadata/.plugins/org.eclipse.core.resources/.root:
total 292
drwxr-x--- 3 sprigogin eng   4096 Jun  9 15:10 .
drwxr-x--- 6 sprigogin eng   4096 Jun  9 15:20 ..
-rw-r----- 1 sprigogin eng 284231 Jun  9 15:10 106.tree
drwxr-x--- 2 sprigogin eng   4096 Oct 11  2013 .indexes

The .snap file is 3 days older than the tree!

The type of the resulting inconsistency can be illustrated by the following code:

DeltaDataTree trees[] = new DeltaDataTree[4];

// These trees come from 106.tree file.
AbstractDataTreeNode n;
n = new DataTreeNode("one", "/one", new AbstractDataTreeNode[] {});
n = new DataTreeNode("", "/", new AbstractDataTreeNode[] {n});
trees[0] = new DeltaDataTree(n);
trees[0].immutable();

n = new DataTreeNode("three", "/one/two/three");
n = new DataTreeNode("two", "/one/two", new AbstractDataTreeNode[] {n});
n = new DataDeltaNode("one", "/one", new AbstractDataTreeNode[] {n});
n = new DataDeltaNode("", "/", new AbstractDataTreeNode[] {n});
trees[1] = new DeltaDataTree(n, trees[0]);
trees[1].immutable();

// These trees come from the out-of-date .snap file.
n = new DataTreeNode("other", "/other");
n = new NoDataDeltaNode("", new AbstractDataTreeNode[] {n});
trees[2] = new DeltaDataTree(n, trees[0]);  // Here is the the problem
trees[2].immutable();

n = new DataDeltaNode("three", "/one/two/three");
n = new NoDataDeltaNode("two", new AbstractDataTreeNode[] {n});
n = new NoDataDeltaNode("one", new AbstractDataTreeNode[] {n});
n = new DataDeltaNode("", "/", new AbstractDataTreeNode[] {n});
trees[3] = new DeltaDataTree(n, trees[2]);
trees[3].immutable();

trees[3].reroot();  // throws ObjectNotFoundException: Tree element '/one/two/three' not found.
Comment 4 Sergey Prigogin CLA 2014-06-20 21:48:55 EDT
The proposed fix is in https://git.eclipse.org/r/#/c/28845/

The fix changes the name of the tree snapshot file from .snap to
<sequence_number>.snap, where the sequence number matches the sequence
number of the tree file. With this change a failure to delete a snapshot
file after creating a new tree file is no longer fatal since the
leftover snapshot file would not match the sequence number of the tree
file and will be ignored while restoring the workspace.

Backward compatibility is achieved by checking for the .snap file if the
<sequence_number>.snap file is not found. The .snap file is accepted
only if its last modification time is not lower than the last
modification time of the tree file.
Comment 5 Sergey Prigogin CLA 2014-06-20 21:53:27 EDT
I couldn't figure out how to write an automated test that would test workspace loading with an out-of-date snapshot file. Any ideas on how to do that will be appreciated.
Comment 6 John Arthorne CLA 2014-07-17 16:25:12 EDT
The fix looks good to me, and I have merged into master:

http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=e332a711becfbd40358308857dd4b69defbd1299

We have a suite of "session" tests in org.eclipse.core.tests.resources.session. I think this infrastructure could be used to write a test for this scenario.

I see you want to target this for 4.4.1, so I will leave this open and we'll first confirm that all is well in the 4.5/master branch.
Comment 7 Sergey Prigogin CLA 2014-08-22 14:39:31 EDT
(In reply to John Arthorne from comment #6)
> I see you want to target this for 4.4.1, so I will leave this open and we'll
> first confirm that all is well in the 4.5/master branch.

We haven't seen any problems in 4.5. We should probably either cherry pick the fix to R4_4_maintenance now or retarget the bug.
Comment 8 Szymon Ptaszkiewicz CLA 2014-08-25 10:36:41 EDT
(In reply to Sergey Prigogin from comment #7)
> (In reply to John Arthorne from comment #6)
> > I see you want to target this for 4.4.1, so I will leave this open and we'll
> > first confirm that all is well in the 4.5/master branch.
> 
> We haven't seen any problems in 4.5. We should probably either cherry pick
> the fix to R4_4_maintenance now or retarget the bug.

Mars M1 was released last Friday so it hasn't been tested thoroughly, but the fix looks good so we can go ahead with the backport. Fixed in R4_4_maintenance:

http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?h=R4_4_maintenance&id=6d731e6a228429caed8a0077302e31bd4f8d8185
Comment 9 Roman A. CLA 2015-12-22 17:08:54 EST
I'm still getting this error:
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200
I noticed, it happens when you start eclipse and while the projects of the current workspace are still building you switch to another workspace-> xx.snap files are created in the .metadata/.plugins/org.eclipse.core.resources directory. After you try to switch back to this workspace you get the error

quite annoying.
kind regards
rome
Comment 10 Dani Megert CLA 2016-01-05 09:15:45 EST
(In reply to Roman A. from comment #9)
> I'm still getting this error:
> Version: Mars.1 Release (4.5.1)
> Build id: 20150924-1200
> I noticed, it happens when you start eclipse and while the projects of the
> current workspace are still building you switch to another workspace->
> xx.snap files are created in the
> .metadata/.plugins/org.eclipse.core.resources directory. After you try to
> switch back to this workspace you get the error
> 
> quite annoying.
> kind regards
> rome

Please open a new bug with steps to reproduce and cc me.