/* * To avoid deadlocks, we'd better drop the leaf page lock * before going further. */ _bt_unlockbuf(rel, leafbuf);
/* * Check that the left sibling of leafbuf (if any) is not * marked with INCOMPLETE_SPLIT flag before proceeding */ Assert(leafblkno == scanblkno); if (_bt_leftsib_splitflag(rel, leftsib, leafblkno)) { ReleaseBuffer(leafbuf); return; }
After unlocking leaf, but before call _bt_leftsib_splitflag, leftsib may be already split, and leafbuf's current left sibling is in INCOMPLETE_SPLIT status.
# how to fix
In function _bt_leftsib_splitflag, after lock leftsib, we should lock leafbuf again, then recheck if leafbuf's leftsib is still leftsib, if check passed, keep lock on leafbuf.