Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327387 - Better aligning of CDO and EMF notifications
Summary: Better aligning of CDO and EMF notifications
Status: NEW
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.13   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: odte
Keywords:
Depends on:
Blocks: 389173
  Show dependency tree
 
Reported: 2010-10-09 06:51 EDT by Markus Barchfeld CLA
Modified: 2020-12-11 10:37 EST (History)
2 users (show)

See Also:


Attachments
Test an patch for CDO 3.0 Maintenance Branch (36.17 KB, patch)
2010-10-09 06:54 EDT, Markus Barchfeld CLA
no flags Details | Diff
Patch for notification handling based on HEAD of 20101031 (28.05 KB, patch)
2010-10-31 14:45 EDT, Markus Barchfeld CLA
no flags Details | Diff
FailureList (144.26 KB, text/plain)
2010-11-13 05:58 EST, Eike Stepper CLA
no flags Details
Patch v2 (29.71 KB, patch)
2010-11-13 06:01 EST, Eike Stepper CLA
no flags Details | Diff
Fixed test issues, implemented testDeliverNotificationWithLists and testDeliverNotificationsTwoObjects (56.71 KB, patch)
2010-11-21 11:11 EST, Markus Barchfeld CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Barchfeld CLA 2010-10-09 06:51:45 EDT
Build Identifier: 3.5

Let's begin with a short example to motivate this request for an enhancement:

There are two CDO transactions t1 and t2 connected to the same resource, with o1 being a CDO object retrieved from t1 and o2 from t2. At least t1 must have it's change subscription policy set to CDOAdapterPolicy.

session1:
o1.eAdapters().add(notificationHandler1);

session2:
assert o2.getStreet() == null
o2.eAdapters().add(notificationHandler2);
o2.setName("me");
o2.setStreet("street");
o2.setName("you");
t2.commit();


In the case of o2 the adapter is called with the regular EMF mechanism for dispatching notifications. In the case of o1 CDO handles the dispatch of notifications during the process of updating the session (delivering passive updates or "session invalidation"). Only if both dispatch mechanism were completely compatible, the notification handler could be unaware of the scenario in which they are used. Unfortunately, there are some differences, which troubled us while porting an application with sophisticated notification handling to CDO. Some of the differences are:

* the order of CDO notifications is random. The notification handler for o2 is called at first with the notification concerning the change of the name and after that with a notification for the change of the street. However, the order in which the handler for o1 is called is undefined.
* CDO applies *all* change deltas first and later dispatches the notifications. Therefore the state of the notifier is different in both scenarios. When the handler of o2 is notified about the change of the name, o2.getStreet() will return null. However, when the handler of o1 is notified o1.getStreet() will return "street".
* CDO optimizes change deltas. Therefore notificationHandler2 is called for both "me" and "you" whereas notificationHandler1 is only called for "you" 

I think that it would mitigate the effort to migrate applications to CDO with CDO notifications being as close as possible to EMF notifications. On the other side I think that optimization is an issue, too. So, maybe an option to switch to a "dispatch compatibility mode" would be best. Attached you find some tests and a very raw implementation which addresses the three issues. In particular the "old value" argument is not determined correctly and conflicts are ignored. 
I would be glad if this enhancement would be considered useful for other users of CDO, too.

Reproducible: Always

Steps to Reproduce:
enhancement.
Comment 1 Markus Barchfeld CLA 2010-10-09 06:54:46 EDT
Created attachment 180545 [details]
Test an patch for CDO 3.0 Maintenance Branch
Comment 2 Eike Stepper CLA 2010-10-30 03:55:16 EDT
Hi Markus, I wanted to take a quick look at your changes but unfortunately they seem entirely out of sync with current HEAD. Can you please try provide an updated patch?
Comment 3 Markus Barchfeld CLA 2010-10-31 14:45:26 EDT
Created attachment 182119 [details]
Patch for notification handling based on HEAD of 20101031

There are four tests, from which only three are green. The purpose of the remaining test (testDeliverNotificationsTwoObjects) is only to show the tough case Eike mentioned as being critical.
Comment 4 Eike Stepper CLA 2010-10-31 15:13:37 EDT
Hi Markus, 

Thank you for re-aligning the patch! 

Experience showed that it is unlikely that I will get to normal work during the Eclipse Summit. I'll probably look at your patch after it ;-)
Comment 5 Eike Stepper CLA 2010-11-13 05:58:19 EST
Some comments so far:

- What is notification.getEventType() != -1, see CDONotificationBuilder.CDONotificationDispatcherVisitor.dispatch(CDOFeatureDelta)

- CDO AllTests has 7 errors and 43 failures with your patch applied. Some of them are related with detachment, some with multi-session notification. I'll attach the complete failure list, but I would also like you to run the test suite yourself.

- You may want to set your name as author in the new files. Please confirm that:
1) You are the only author of these changed lines.
2) You apply the EPL to these changed lines.
Comment 6 Eike Stepper CLA 2010-11-13 05:58:45 EST
Created attachment 183076 [details]
FailureList
Comment 7 Eike Stepper CLA 2010-11-13 06:01:17 EST
Created attachment 183077 [details]
Patch v2
Comment 8 Pascal Lehmann CLA 2010-11-15 03:40:13 EST
Just a sidenote when looking at the patch: Using CDOFeatureDelta as the key in a hashmap or in lists might have some undesired bahaviour since the implementation of hashcode/equals will lead to the same result for different CDOFeatureDeltas.
Comment 9 Markus Barchfeld CLA 2010-11-21 11:11:46 EST
Created attachment 183536 [details]
Fixed test issues, implemented testDeliverNotificationWithLists and testDeliverNotificationsTwoObjects
Comment 10 Markus Barchfeld CLA 2010-11-21 11:29:13 EST
The latest version of the patch uses a switch on the view to enable/disable the new behavior. It has become less intrusive and the test suite (AllTests) is fine now. Except for one of the new tests for notification delivery which fails with CDO Legacy adapter. I have not looked into that yet.

Pascal, I  use CDOFeatureDelta in a sorted map as key. What would you suggest to avoid the "undesired behavior" you mentioned?

How do we proceed? Could someone (Eike) review the patch and then decide if it is going to make it and/or what else needs to be done?

I had no time yet to run our application on top of the patched CDO and check how much it has improved. I guess that I will find some more issues once I do so. However, before I spend more time on the patch I would like to know if the direction is OK.

Thanks 
Markus
Comment 11 Pascal Lehmann CLA 2010-11-23 06:54:16 EST
I tried different workarounds such as using IdentityHashMaps, wrapper objects, using the index in case of a list instead of the CDOFeature itself or using my utility methods which were trying to use instance equal whenever possible.

For all solutions using the instance to compare you get problems whenever a copy of the delta is made, or whenever a CDOMoveFeatureDelta has to be recreated (see Bug #330904).

To have a general solution which works without doing any workarounds, I think we need to add something to the CDOFeatureDeltas which makes them more distinguishable without breaking the equality needed inside CDO itself.
I opened another bugzilla, so we can discuss it there: https://bugs.eclipse.org/bugs/show_bug.cgi?id=330903
Comment 12 Eike Stepper CLA 2010-12-21 10:01:27 EST
Markus, I was just trying to apply your patch but these two files show conflicts:

CDOFeatureDeltaImpl.java
CDORevisionDeltaImpl.java

Can you please try to update the patch with HEAD? Sorry for the unconvenience...
Comment 13 Markus Barchfeld CLA 2011-01-02 03:28:24 EST
(In reply to comment #12)
> Can you please try to update the patch with HEAD? Sorry for the
> unconvenience...

Hi Eike,

Thanks for your answer. I think the patch worked fine when I added it here a couple of weeks ago. I guess that things have moved on in the meantime. Unfortunately, I can not care for it at the moment. With regard to the time and effort I put into the patch already I would really appreciate if you could have another look and maybe fix it. I would expect failures to be related to recent changes.

Thanks
Markus
Comment 14 Eike Stepper CLA 2011-01-02 03:33:20 EST
Hi Markus,

From the hours I've already spent on your desire you can see that I appreciate your efforts very much. Unfortunately CVS patches can go out of sync and they usually do if a project is active. As you know best what you've originally changed it's your task to bring them up to date again. I hope that you understand that I can not do this.

Cheers
/Eike
Comment 15 Eike Stepper CLA 2011-06-23 03:57:42 EDT
Moving all open enhancement requests to 4.1
Comment 16 Eike Stepper CLA 2012-08-14 22:51:34 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 17 Eike Stepper CLA 2013-06-27 04:06:34 EDT
Moving all outstanding enhancements to 4.3
Comment 18 Eike Stepper CLA 2014-08-19 09:24:14 EDT
Moving all open enhancement requests to 4.4
Comment 19 Eike Stepper CLA 2014-08-19 09:35:31 EDT
Moving all open enhancement requests to 4.4
Comment 20 Eike Stepper CLA 2015-07-14 02:10:15 EDT
Moving all open bugzillas to 4.5.
Comment 21 Eike Stepper CLA 2016-07-31 00:52:55 EDT
Moving all unaddressed bugzillas to 4.6.
Comment 22 Eike Stepper CLA 2017-12-28 01:10:55 EST
Moving all open bugs to 4.7
Comment 23 Eike Stepper CLA 2019-11-08 02:07:57 EST
Moving all unresolved issues to version 4.8-
Comment 24 Eike Stepper CLA 2019-12-13 12:53:12 EST
Moving all unresolved issues to version 4.9
Comment 25 Eike Stepper CLA 2020-12-11 10:37:12 EST
Moving to 4.13.