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

Bug 477046

Summary: Corrupted aird files when retrieving a project from SCM after an uncontrol
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: CLOSED FIXED QA Contact: Florian Barbin <florian.barbin>
Severity: normal    
Priority: P3 CC: esteban.dugueperoux, florian.barbin, laurent.redor, pierre-charles.david, stephane.thibaudeau
Version: 3.0.0Keywords: triaged
Target Milestone: 4.0.0M4   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/55631
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d19a3e61524136c136cc2642e0f8342e6b961aa2
Whiteboard:
Bug Depends on: 475834    
Bug Blocks:    

Description Pierre-Charles David CLA 2015-09-10 05:17:37 EDT
+++ This bug was initially created as a clone of Bug #475834 +++

2 users share a same modeling project using a SCM.
At first, the project contains controlled resources (both semantic and graphical).
When one of the users uncontrols the resources, the other users gets errors when retrieving the project from the SCM.


Steps to reproduce :
- in a first workspace (WS1), import the provided project
- in a second workspace (WS2), import the same provided project
- in WS1, select "newPackage1" in fragments/My_newPackage1.ecore and right-click on "uncontrol". Answer "yes" when Sirius asks whether the graphical resource should be uncontrolled too. => everything is OK in WS1 (2 files have been deleted, 2 files have been modified)
- using the filesystem (not inside eclipse), copy the project from WS1 to WS2. I personnally delete everything except the .project file in WS2, select the whole contents except the .project file in WS1 and copy these files into WS2
- in Eclipse/WS2, refresh the project
=> a first dialog displays a warning about the deleted aird (it's not very useful...)
=> click yes : an error occurs while loading the models (Sirius considers there are 2 main aird files even if one of them is deleted)
=> the deleted aird is still present but empty
=> the main aird is empty.
Comment 1 Pierre-Charles David CLA 2015-09-10 05:25:11 EDT
Cloned from #475834 to report the fix on master for Sirius 3.1.0.

As mentioned by Esteban in https://bugs.eclipse.org/bugs/show_bug.cgi?id=475834#c1, the symptoms are not exactly the same on master as they were on v2.0.x (I reproduce the stack Esteban saw on current master).

The patch from http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=36e28c09b9232b5201aa4508f375fd21496162a4 seems to also fix the issue on master, but more investigation is needed to understand the behavior difference before merging this. On master there is also a problem in the "Model Explorer" refreshment after the operation: initialy the reloaded aird can not be expanded anymore. Simply collapsing/expanding the parent project fixes the issue, and then everything seems fine, so it may be simply a UI synchronization issue.

I'll push a draft review simply cherry-picking the v2.0.x fix on master to get the Gerrit builds feedback, but as mentioned above, more work is needed to better understand the ins and outs of the issue and fix before merging this on master.
Comment 2 Eclipse Genie CLA 2015-09-10 05:26:51 EDT
New Gerrit change created: https://git.eclipse.org/r/55631
Comment 3 Laurent Redor CLA 2015-09-11 04:55:28 EDT
The above gerrit does not resolved completely the initial problem. As said by Pierre-Charles 
> On master there is also a problem in the "Model Explorer" refreshment after the operation: initialy the reloaded aird can not be expanded anymore.

This is caused by the fact that the session is closed during the refresh.
SessionManagerImpl.remove(Session) is called by DAnalysisSessionImpl.close(IProgressMonitor), that is called by the ReloadingPolicy when the My_newPackage1.aird is removed --> ReloadingPolicyImpl.handleExternalDelete(Session, Resource, ResourceStatus).

	SessionManagerImpl.remove(Session) line: 149	
	DAnalysisSessionImpl.close(IProgressMonitor) line: 1234	
	SessionResourcesSynchronizer.processAction(ReloadingPolicy$Action, Resource, IProgressMonitor) line: 164	
	SessionResourcesSynchronizer.processActions(List<Action>, Resource, IProgressMonitor) line: 157	
	SessionResourcesSynchronizer.statusesChanged(Collection<ResourceStatusChange>) line: 106	
	ResourceSetSync.notifyClientsInBatch(Collection<ResourceStatusChange>) line: 392	
	ResourceSetSync.statusesChanged(Collection<ResourceStatusChange>) line: 447
Comment 4 Laurent Redor CLA 2015-09-11 06:05:18 EDT
The probem of closed session after refresh is the same on current state of Sirius v2.0.x branch (with commit 36e28c of bug 475834).
Comment 6 Pierre-Charles David CLA 2015-09-28 04:10:37 EDT
The patch present in 3.1.0 fixes the most important issue (data loss/corruption). Moving the ticket to 4.0 to have a look at the remaining issues, which can relatively easily be worked around for now (closing/reopening the project/session restores a usable state).
Comment 7 Florian Barbin CLA 2016-05-20 10:43:08 EDT
Verified on Verified on Sirius 4.0.0.201605180923
Comment 8 Pierre-Charles David CLA 2016-06-24 08:00:43 EDT
Available in Sirius 4.0.0.