• Peter Geoghegan's avatar
    Fix nbtree kill_prior_tuple posting list assert. · ce2cee0a
    Peter Geoghegan authored
    An assertion added by commit 0d861bbb checked that _bt_killitems() only
    processes a BTScanPosItem whose heap TID is contained in a posting list
    tuple when its page offset number still matches what is on the page
    (i.e. when it matches the posting list tuple's current offset number).
    This was only correct in the common case where the page can't have
    changed since we first read it.  It was not correct in cases where we
    don't drop the buffer pin (and don't need to verify the page hasn't
    changed using its LSN).  The latter category includes scans involving
    unlogged tables, and scans that use a non-MVCC snapshot, per the logic
    originally introduced by commit 2ed5b87f.
    
    The assertion still seems helpful.  Fix it by taking cases where the
    page may have been concurrently modified into account.
    
    Reported-By: Anastasia Lubennikova, Alexander Lakhin
    Discussion: https://postgr.es/m/c4e38e9a-0f9c-8e53-e639-adf343f94472@postgrespro.ru
    ce2cee0a
nbtutils.c 84.4 KB