You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Use an MVCC snapshot, rather than SnapshotNow, for catalog scans.
SnapshotNow scans have the undesirable property that, in the face ofconcurrent updates, the scan can fail to see either the old or the newversions of the row. In many cases, we work around this by requiringDDL operations to hold AccessExclusiveLock on the object beingmodified; in some cases, the existing locking is inadequate and randomfailures occur as a result. This commit doesn't change anythingrelated to locking, but will hopefully pave the way to allowing lockstrength reductions in the future.The major issue has held us back from making this change in the pastis that taking an MVCC snapshot is significantly more expensive thanusing a static special snapshot such as SnapshotNow. However, testingof various worst-case scenarios reveals that this problem is notsevere except under fairly extreme workloads. To mitigate thoseproblems, we avoid retaking the MVCC snapshot for each new scan;instead, we take a new snapshot only when invalidation messages havebeen processed. The catcache machinery already requires thatinvalidation messages be sent before releasing the related heavyweightlock; else other backends might rely on locally-cached data ratherthan scanning the catalog at all. Thus, making snapshot reusedependent on the same guarantees shouldn't break anything that wasn'talready subtly broken.Patch by me. Review by Michael Paquier and Andres Freund.