viatra / EMF-IncQuery

This repository is only kept for historic reasons. All development happens on eclipse.org
http://eclipse.org/viatra
13 stars 4 forks source link

Duplicate deletion in ITC #361

Closed abelhegedus closed 11 years ago

abelhegedus commented 11 years ago

Short version: it is possible to reach a state where the ITC algorithm sends duplicate removal messages to the Rete engine, causing an exception.

Long version: When two specific (and quite complex) queries are both matched on a model, removing elements from the model, that changes the result sets of these queries, results in erroneous messages from the ITC.

I have queries and models and a test code that consistently reproduces the error:

The test loads an Ecore model and a pattern model with some queries, including several transitive closure ones. After initial matching, some of the EClasses are deleted. If the "canTransitivelyContain" and the "reference" queries are both matched, the error occurs. If only one or neither is there, it doesn't.

We have instrumented the TransitiveClosureNode to see what kind of messages are used at the initialization and later in the model modification case.

This output is expressed in the following: https://gist.github.com/4067344#file_transitive_closure_node

@bergmanngabor even created a small drawing of the setup: https://www.dropbox.com/s/8heupfugcmtqlwu/WP_000168.jpg

The deletion of the "OTCPM->RCP" (abbreviations for the classes in the test Ecore model) edge is the catalyst of the problems.

bergmanngabor commented 11 years ago

The deletion of the "OTCPM->RCP" (abbreviations for the classes in the test Ecore model) edge is the catalyst of the problems.

Yes, the TC algorithm will report the loss of transitive reachability D--..->RC and G-..->RC, even though they still have an alternate derivation due to base edge D->RC. The exception will only be triggered, of course, when the loss of the same pairs will be reported again by the TC node; but this "OTCPM->RCP" deletion is when the TC actually goes wrong.

szabta89 commented 11 years ago

@abelhegedus Can you upload to code as a plug-in in order for me to test it?

abelhegedus commented 11 years ago

The attached code is a completely working JUnit Plug-in Test that uses absolute file paths to load the test inputs that I also uploaded.

However, here is the project I used: https://www.dropbox.com/s/q8lx758hobo7btx/test.multi.genpackage.zip

szabta89 commented 11 years ago

@abelhegedus What can I do to make the test more deterministic? Redoing the same sequence of steps from your trace does not result an NPE for me, however, I do have encountered NPE when running the test of yours.

szabta89 commented 11 years ago

@abelhegedus Please take a look at the current state of the code. I think the previous commit solved the issue.

abelhegedus commented 11 years ago

Yes, the issue is gone. Thank you!

abelhegedus commented 11 years ago

Reopening, as cherry picking is needed, I think.

szabta89 commented 11 years ago

@abelhegedus Cherry pick is done.

ujhelyiz commented 11 years ago

@szabta89 Please, write comments in your source code.

Please, also confirm that the test case deterministically reproduces the original issue, and your fix resolves it.

szabta89 commented 11 years ago

@ujhelyiz The test case reproduces the problem deterministically and the commit solved it. There was a problem with the initialization of the Counting algorithm (the IncSCC depends on it). I'm gonna pay more attention on the comments.