postgresql/src/backend/utils
Robert Haas 568d4138c6 Use an MVCC snapshot, rather than SnapshotNow, for catalog scans.
SnapshotNow scans have the undesirable property that, in the face of
concurrent updates, the scan can fail to see either the old or the new
versions of the row.  In many cases, we work around this by requiring
DDL operations to hold AccessExclusiveLock on the object being
modified; in some cases, the existing locking is inadequate and random
failures occur as a result.  This commit doesn't change anything
related to locking, but will hopefully pave the way to allowing lock
strength reductions in the future.

The major issue has held us back from making this change in the past
is that taking an MVCC snapshot is significantly more expensive than
using a static special snapshot such as SnapshotNow.  However, testing
of various worst-case scenarios reveals that this problem is not
severe except under fairly extreme workloads.  To mitigate those
problems, we avoid retaking the MVCC snapshot for each new scan;
instead, we take a new snapshot only when invalidation messages have
been processed.  The catcache machinery already requires that
invalidation messages be sent before releasing the related heavyweight
lock; else other backends might rely on locally-cached data rather
than scanning the catalog at all.  Thus, making snapshot reuse
dependent on the same guarantees shouldn't break anything that wasn't
already subtly broken.

Patch by me.  Review by Michael Paquier and Andres Freund.
2013-07-02 09:47:01 -04:00
..
adt Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
cache Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
error Renovate display of non-ASCII messages on Windows. 2013-06-26 11:17:33 -04:00
fmgr Add infrastructure for storing a VARIADIC ANY function's VARIADIC flag. 2013-01-21 20:26:15 -05:00
hash pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
init Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
mb Renovate display of non-ASCII messages on Windows. 2013-06-26 11:17:33 -04:00
misc Support TB (terabyte) memory unit in GUC variables. 2013-06-20 08:17:14 +09:00
mmgr Permit super-MaxAllocSize allocations with MemoryContextAllocHuge(). 2013-06-27 14:53:57 -04:00
resowner pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
sort Permit super-MaxAllocSize allocations with MemoryContextAllocHuge(). 2013-06-27 14:53:57 -04:00
time Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
.gitignore Avoid maintaining three separate copies of the error codes list. 2011-02-03 22:32:49 -05:00
errcodes.txt Update copyrights for 2013 2013-01-01 17:15:01 -05:00
Gen_dummy_probes.sed Update copyrights for 2013 2013-01-01 17:15:01 -05:00
Gen_fmgrtab.pl Update copyrights for 2013 2013-01-01 17:15:01 -05:00
generate-errcodes.pl Update copyrights for 2013 2013-01-01 17:15:01 -05:00
Makefile Make handling of errcodes.h more consistent with other generated headers. 2011-02-04 09:29:10 -05:00
probes.d Update copyrights for 2013 2013-01-01 17:15:01 -05:00