comdb2 icon indicating copy to clipboard operation
comdb2 copied to clipboard

PORTED R7 Fix: Get lock on node about to be split to avoid insert in wrong order

Open adizaimi opened this issue 4 years ago • 0 comments

Bug is that when insertion into an index is contended, sometimes we get values inserted in the wrong location (out of order). The reason for this bug is because we removed the cget() call in a previous checkin, however that cget() call write locks the page we are going to write. That write lock ensures that if we need to split the page, no other thread will sneak past and perform the split. Without that write lock, another thread can do the split of this node and we are left with a pointer to the left subtree--that is the wrong place to start search to perform the insert, thus we were getting wrong order in some of the keys inserted. One solution is to perform bam_search from the root node rather than from the result of a split. However a better solution is to write lock the page before splitting it, so we are ensured to be the ones performing the split. PR to masterbranch #1999.

adizaimi avatar May 08 '20 05:05 adizaimi