neo4j/neo4j — pull request #974 by thobe (2013-07-16 16:54:51+00:00)
Title: Resolves issue where removing multiple labels from a node with a large number of labels would result in corruption.

This problem manifested in scenarios when a node has so many labels that multiple
dynamic records are used for holding them.

The problem was that when a label was removed that caused one of the dynamic records
to not be in use anymore, this record would be marked as !inUse, which makes it light.
If in the same transaction another label is removed from that same node, the labels are
first read from the records, including the one marked as !inUse. Since this record is light,
reading data from it will cause it to be made heavy, reading back the data from the store
into it, thus reading back data that should have been removed, leading to an inconsistent
state.

The solution implemented is to also mark the record as empty, meaning that when the
record is made heavy as part of reading the labels from it, no data will be read (a byte[0]).
A simple optimization has been implemented for the case when a record is empty, to not
actually read any data from the store, only mark it as heavy by assigning a pre-allocated
byte[0].