neo4j/neo4j — pull request #2953 by tinwelint (2014-08-28 14:48:44+00:00)
Title: Store application ordering of transactions w/ legacy index changes

Only a single transaction at a time can append to the log buffer, but
multiple transactions can apply changes onto the store simultaneously in
2.2. For graph and schema indexing changes there are the high level
entity locks that guarantee correct ordering of transactions wanting to
change the same records. However for legacy indexes there are no such
ordering. This might result in for example an REMOVE+ADD turning into a
ADD+REMOVE, i.e. two different end results.

So, this commit introduces ordering of transactions making any legacy
index changes so that such transactions gets applied in the same order
as they were appended to the log. Transactions that doesn't change
any legacy indexes will not be ordered like this and will pay no cost
whatsoever for the ordering introduces here.

This commit also adds apply() to NeoCommandHandler such that
CommandApplierFacade can call a round of apply() to all appliers and the
another round of close(). This fixes an issue where store application
locks would be released too soon.
Previously:
* apply graph changes
* release graph update locks
* apply schema index changes
* apply legacy index changes

Now:
* apply graph changes
* apply schema index changes
* apply legacy index changes
* release graph update locks