postgresql/src/backend/commands
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
..
aggregatecmds.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
alter.c Don't pass oidvector by value. 2013-06-12 19:50:37 -04:00
analyze.c Arrange to cache FdwRoutine structs in foreign tables' relcache entries. 2013-03-06 23:48:09 -05:00
async.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
cluster.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
collationcmds.c Refactor ALTER some-obj RENAME implementation 2013-01-21 12:06:41 -03:00
comment.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
constraint.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
conversioncmds.c Refactor ALTER some-obj RENAME implementation 2013-01-21 12:06:41 -03:00
copy.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
createas.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
dbcommands.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
define.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
discard.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
dropcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
event_trigger.c Don't use ordinary NULL-terminated strings as Name datums. 2013-06-12 19:49:50 -04:00
explain.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
extension.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
foreigncmds.c Extend object-access hook machinery to support post-alter events. 2013-03-17 22:57:26 -04:00
functioncmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
indexcmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
lockcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
Makefile Add a materialized view relations. 2013-03-03 18:23:31 -06:00
matview.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
opclasscmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
operatorcmds.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
portalcmds.c Only install a portal's ResourceOwner if it actually has one. 2013-06-13 13:12:49 -04:00
prepare.c Clean up the mess around EXPLAIN and materialized views. 2013-04-12 19:25:31 -04:00
proclang.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
schemacmds.c Editorialize a bit on new ProcessUtility() API. 2013-04-28 00:18:45 -04:00
seclabel.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
sequence.c Add buffer_std flag to MarkBufferDirtyHint(). 2013-06-17 08:02:12 -07:00
tablecmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
tablespace.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
trigger.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
tsearchcmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
typecmds.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
user.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
vacuum.c Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
vacuumlazy.c Ensure that XLOG_HEAP2_VISIBLE always targets an initialized page. 2013-06-06 10:21:47 -04:00
variable.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
view.c Clean up the mess around EXPLAIN and materialized views. 2013-04-12 19:25:31 -04:00