• Tim Peters's avatar
    Fixing a rare BTree conflict resolution error. · 9259274f
    Tim Peters authored
    + Transaction T1 deletes some of the keys in bucket B,
      but not all of the keys.
    
    + Transaction T2 deletes (exactly) the keys in B that
      aren't deleted by T1.
    
    The version of B each transaction sees is then non-empty,
    but conflict resolution creates an empty bucket.  However,
    conflict resolution doesn't have enough info to unlink an
    empty bucket from its containing BTree correctly.
    
    The result is that an empty bucket is left in the BTree,
    which violates a BTree invariant.  The most probable
    symptom is a segfault, when later & unrelated code tries
    to access this bucket:  an empty bucket has NULL
    pointers where the vectors of keys and values should be,
    and accessing code tries to dereference the NULL pointers.
    
    I don't know that this error has been seen in real life.
    It was provoked by a randomized multithreaded simulation
    program that was trying to provoke errors.  This error was
    provoked frequently by that program; no other kinds of
    errors have come out of it.
    9259274f
testConflict.py 21.1 KB