In the past, parent nodes were not (write) locked when child nodes
were added or removed.
With PL, we simply got a read lock on a parent and edited the child
map. This allowed for phantom reads (and TBH wasn't really R_R either).
With OL, we didn't increment parent versioning when children were
added or removed, but attempted to merge child maps.
For both of the above, we introduced a LockParentForChildInsertRemove
system-wide config property (which defaulted to false). If true, a WL
was acquired on parents (PL) or parent versioning was incremented and
validated (OL) when adding/removing children.
Now with MVCC - since there are no read locks - we have a problem.
Consider:
1. Tx begns.
2. Tx reads /a (no locks)
3. Tx removes /a/b (locks /a/b)
4. Tx counts children of /a (will still see that /a/b is in /a's
child map).
he approaches I have considered are:
1. Removing /a/b from /a's child map.
This will provide a consistent view to the tx removing /a/b but will
mean that other txs will also see /a/b disappear when counting /a's
children, but not when querying the cache for /a/b! Worse, rollbacks
would mean re-adding /a/b to /a's child map, providing weird views on
other readers (/a/b disappears for a while, then reappears)
2. Make a copy of /a for the tx to work off, when removing /a/b.
This is the same as having LockParentForChildInsertRemove semantics.
Copy the parent as well and work off it, but to prevent problems with
concurrent child removes and adds, we'd have to lock the parent.
My vote is for approach 2. In fact, LockParentForChildInsertRemove
would always need to be enabled when using MVCC. Perhaps this should
be a deprecated property that just supports additional consistency for
OL and PL, and be removed when OL/PL eventually get removed?
Thoughts?
--
Manik Surtani
Lead, JBoss Cache
manik(a)jboss.org