postgresql/src/backend/commands
Tom Lane c2a14bc7c9 Protect against SnapshotNow race conditions in pg_tablespace scans.
Use of SnapshotNow is known to expose us to race conditions if the tuple(s)
being sought could be updated by concurrently-committing transactions.
CREATE DATABASE and DROP DATABASE are particularly exposed because they do
heavyweight filesystem operations during their scans of pg_tablespace,
so that the scans run for a very long time compared to most.  Furthermore,
the potential consequences of a missed or twice-visited row are nastier
than average:

* createdb() could fail with a bogus "file already exists" error, or
  silently fail to copy one or more tablespace's worth of files into the
  new database.

* remove_dbtablespaces() could miss one or more tablespaces, thus failing
  to free filesystem space for the dropped database.

* check_db_file_conflict() could likewise miss a tablespace, leading to an
  OID conflict that could result in data loss either immediately or in
  future operations.  (This seems of very low probability, though, since a
  duplicate database OID would be unlikely to start with.)

Hence, it seems worth fixing these three places to use MVCC snapshots, even
though this will someday be superseded by a generic solution to SnapshotNow
race conditions.

Back-patch to all active branches.

Stephen Frost and Tom Lane
2013-01-18 18:06:20 -05:00
..
Makefile Syntax support and documentation for event triggers. 2012-07-18 10:16:16 -04:00
aggregatecmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
alter.c Rework order of checks in ALTER / SET SCHEMA 2013-01-15 13:23:43 -03:00
analyze.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
async.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
cluster.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
collationcmds.c Rework order of checks in ALTER / SET SCHEMA 2013-01-15 13:23:43 -03:00
comment.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
constraint.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
conversioncmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
copy.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
createas.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
dbcommands.c Protect against SnapshotNow race conditions in pg_tablespace scans. 2013-01-18 18:06:20 -05: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 Update copyrights for 2013 2013-01-01 17:15:01 -05:00
explain.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
extension.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
foreigncmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
functioncmds.c Rework order of checks in ALTER / SET SCHEMA 2013-01-15 13:23:43 -03:00
indexcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
lockcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
opclasscmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
operatorcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
portalcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
prepare.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
proclang.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
schemacmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
seclabel.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
sequence.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tablecmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tablespace.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
trigger.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tsearchcmds.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
typecmds.c Make some spelling more consistent 2013-01-05 08:25:21 -05:00
user.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
vacuum.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
vacuumlazy.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
variable.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
view.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00