• Andres Freund's avatar
    Fix race condition between relation extension and vacuum. · fc02e672
    Andres Freund authored
    In e6799d5a I removed vacuumlazy.c trickery around re-checking
    whether a page is actually empty after acquiring an extension lock on
    the relation, because the page is not PageInit()ed anymore, and
    entries in the FSM ought not to lead to user-visible errors.
    
    As reported by various buildfarm animals that is not correct, given
    the way to code currently stands: If vacuum processes a page that's
    just been newly added by either RelationGetBufferForTuple() or
    RelationAddExtraBlocks(), it could add that page to the FSM and it
    could be reused by other backends, before those two functions check
    whether the newly added page is actually new.  That's a relatively
    narrow race, but several buildfarm machines appear to be able to hit
    it.
    
    While it seems wrong that the FSM, given it's lack of durability and
    approximative nature, can trigger errors like this, that seems better
    fixed in a separate commit. Especially given that a good portion of
    the buildfarm is red, and this is just re-introducing logic that
    existed a few hours ago.
    
    Author: Andres Freund
    Discussion: https://postgr.es/m/20190128222259.zhi7ovzgtkft6em6@alap3.anarazel.de
    fc02e672
vacuumlazy.c 72.6 KB