neo4j/neo4j — pull request #1591 by thobe (2013-11-29 15:47:21+00:00)
Title: Index population locks

This solves an issue where the index could contain duplicates of the same node ("the Tom Hanks stunt double").

By mutually excluding the index populator and the application of a transaction to the store files, making them avoid touching anything that relates to the same nodes at the same time, we get a consistent view of the store for the indexes.

Deadlocks are avoided by having only one writer (`WriteTransaction`), and only allowing the writer to acquire multiple locks, while each reader (`NeoStoreIndexStoreView`) may only hold one lock at the time.

Online index population is done from the `WriteTransaction`, while the locks are still held, meaning that the index cannot be "mid-flip" when `commit()` completes, it is either in populating state, and the store will get scanned after the transaction is fully applied, or it is in online state, and the store changes will not have been applied in any other way than through the update hooks from the transaction.