neo4j/neo4j — pull request #2912 by thobe (2014-08-22 11:48:52+00:00)
Title: Evict DenseNode from the cache when deleting all relationships of one type

When a relationship is deleted it needs to be removed from the cache for
the nodes it relates. This is done simply by evicting those nodes from
the cache. In earlier versions the log did not contain any information
about what those nodes were. So instead we based the eviction on the
fact that other, related, records would have changed when a relationship
was deleted, and based eviction on changed records instead.

For dense nodes, when deleting the last relationship of one type, the
records that change are the RelationshipGroup records, Relationship
records are only deleted, and no NodeRecord is (necessarily) updated.
This means that there is no updated record that will cause such an
eviction.

This is only a problem in HA, when we base these actions on records read
from the log. In standalone mode, even deleted relationship records
contain references to the nodes, since they were read from the store
before being put into the transaction state (in memory). When we write
to the log we omit such information, since all we (traditionally) care
about is the record being deleted.

Since the log contains the before-state of records as well as the after-
state, we can now evict nodes based on the before-state. This allows us
to perform eviction based on the very deleted records rather than the
rippling changes it causes. This cleaner eviction policy is what is
implemented in this change set.