Bug 560814 - Model managed by two sessions were inconsistent after several undo operations
Summary: Model managed by two sessions were inconsistent after several undo operations
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 6.3.0   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2020-03-05 08:00 EST by Faycal Abka CLA
Modified: 2020-03-12 08:45 EDT (History)
1 user (show)

See Also:


Attachments
ecore based model (55.46 KB, application/x-zip-compressed)
2020-03-05 08:00 EST, Faycal Abka CLA
no flags Details
Command (35.15 KB, image/png)
2020-03-12 05:08 EDT, Faycal Abka CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Faycal Abka CLA 2020-03-05 08:00:01 EST
Created attachment 282015 [details]
ecore based model

Model managed by two sessions were inconsistent after several undo operations
------------------------------------------------------

I attach I ecore based model to reproduce the issue with screehshoots about the starting state and the result after undoing modification

In the capture validModel.png it is the starting state of my models.
In the capture invalidModel.png is the resulting state after doing the steps described below.

To reproduce :

- Open ecore1 session
- Open ecore1 class diagram
- Open ecore2 session
- Open ecore2 class diagram
- Go to ecore1 class diagram
- Add a new Class and save the session
- Go to ecore2 class diagram
- Add double Attribute de D class and save the session
- do 4 CTRL-Z and save the session

The ecore1 is modified by deleting a newly created class and by deleting names of the classes.

This is a general problem. It is reproduce-able on any model managed by two sessions.
Comment 1 Faycal Abka CLA 2020-03-05 08:07:16 EST
I forget to add that I encontred cases where all elements created in the first resource (ecore1 on the test case) were deleted
Comment 2 Maxime Porhel CLA 2020-03-09 08:37:37 EDT
Hi Faycal, 

From which session do you do the undo ? From the attached invalidModel.png, I assume that you made the undos from session1.

Please note that: 
- the save of ecore1 class diagram (session1) triggers a reload of this resource in session2
- the operation histories and command stacks are specific for each session.
- the model ecore1 is managed/loaded in two different transactional editing domain, a change in the workspace (save) triggers a reload of the model in the other session, with no info on the atomic changes/steps on each model element.

Regards,
Comment 3 Faycal Abka CLA 2020-03-12 05:08:20 EDT
Created attachment 282093 [details]
Command
Comment 4 Faycal Abka CLA 2020-03-12 05:17:50 EDT
Hi Maxim,

I do the undo from the Session2.

The undo/redo mechanism is shared according to the org.eclipse.core.commands.operations.OperationHistoryFactory#getOperationHistory() which is a singleton.

I think, the Resource Synchronizer (org.eclipse.sirius.business.internal.session.danalysis.SessionResourcesSynchronizer) of the session2 add an operation to the shared stack when it detects that the resource of the session 1 is modified.

I the capture I added, shows the command responsible of putting the ecore1 into inconsistent state. I think it is the recording command created in the Resource Synchronizer.

Regards,
Comment 5 Faycal Abka CLA 2020-03-12 05:18:34 EDT
(In reply to Faycal Abka from comment #4)
> Hi Maxim,
> 
> I do the undo from the Session2.
> 
> The undo/redo mechanism is shared according to the
> org.eclipse.core.commands.operations.
> OperationHistoryFactory#getOperationHistory() which is a singleton.
> 
> I think, the Resource Synchronizer
> (org.eclipse.sirius.business.internal.session.danalysis.
> SessionResourcesSynchronizer) of the session2 add an operation to the shared
> stack when it detects that the resource of the session 1 is modified.
> 
> I the capture I added, shows the command responsible of putting the ecore1
> into inconsistent state. I think it is the recording command created in the
> Resource Synchronizer.
> 
> Regards,

Sorry for the typo. Maxime
Comment 6 Maxime Porhel CLA 2020-03-12 07:21:39 EDT
Hi Faycal, 

Your are right, the operation history is a singleton, but each Sirius session has its own undo context.

The issue might come from the reload ; identity of elements is changed and undo might not be correctly managed. 
Sirius might need to flush the command stack/forbid undo when a reload is done.
Comment 7 Faycal Abka CLA 2020-03-12 08:29:26 EDT
Thank you Maxime. keep me aware for the resolution of this issue.

Regards,
Comment 8 Maxime Porhel CLA 2020-03-12 08:45:37 EDT
Hi Faycal, 

The issue has been reproduced. Thanks for the details and reproduction scenario. 

Please note, that it has not been added to a future release yet.

Regards,