• H
    Track "oldestxmin" based on distributed snapshots. · b3f300b9
    Heikki Linnakangas 提交于
    Before this, in order to safely determine if a tuple can be vacuumed away,
    you would need an active distributed snapshot. Even if an XID was older
    than the locally-computed OldestXMin value, the XID might still be visible
    to some distributed snapshot that's active in the QD.
    
    This commit introduces a mechanism to track the "oldest xmin" across any
    distributed snapshots. That makes it possible to calculate an "oldest xmin"
    value in a QE, that covers any such distributed snapshots, even if the
    distributed transaction doesn't currently have an active connection to this
    QE. Every distributed snapshot contains such an "oldest xmin" value, but
    now we track the latest such value that we've seen in this QE, in shared
    memory. Therefore, it's not always 100% up-to-date, but it will reflect
    the situation as of the latest query that was dispatched from QD to this
    QE.
    
    The value returned by GetOldestXmin(), as well as RecentGlobalXmin, now
    includes any distributed transactions. So the value can now be used to
    determine which tuples are dead, like in upstream, without doing the extra
    check with the localXidSatisfiesAnyDistributedSnapshot() function. This
    allows reverting some changes in heap_tuple_freeze.
    
    This allows utility-mode VACUUMs, launched independently in QE nodes, to
    reclaim space. Previously, it could not remove any dead tuples that were
    ever visible to anyone, because it could not determine whether they might
    still be needed by some distributed transaction.
    b3f300b9
procarray.c 79.7 KB