postgresql/src/backend/commands
Noah Misch c6b92041d3 Skip WAL for new relfilenodes, under wal_level=minimal.
Until now, only selected bulk operations (e.g. COPY) did this.  If a
given relfilenode received both a WAL-skipping COPY and a WAL-logged
operation (e.g. INSERT), recovery could lose tuples from the COPY.  See
src/backend/access/transam/README section "Skipping WAL for New
RelFileNode" for the new coding rules.  Maintainers of table access
methods should examine that section.

To maintain data durability, just before commit, we choose between an
fsync of the relfilenode and copying its contents to WAL.  A new GUC,
wal_skip_threshold, guides that choice.  If this change slows a workload
that creates small, permanent relfilenodes under wal_level=minimal, try
adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may
need to adjust that timeout, and log_min_duration_statement analysis
will reflect time consumption moving to COMMIT from commands like COPY.

Internally, this requires a reliable determination of whether
RollbackAndReleaseCurrentSubTransaction() would unlink a relation's
current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the
specification of rd_createSubid such that the field is zero when a new
rel has an old rd_node.  Make relcache.c retain entries for certain
dropped relations until end of transaction.

Bump XLOG_PAGE_MAGIC, since this introduces XLOG_GIST_ASSIGN_LSN.
Future servers accept older WAL, so this bump is discretionary.

Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert
Haas.  Heikki Linnakangas and Michael Paquier implemented earlier
designs that materially clarified the problem.  Reviewed, in earlier
designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,
Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.

Discussion: https://postgr.es/m/20150702220524.GA9392@svana.org
2020-04-04 12:25:34 -07:00
..
aggregatecmds.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
alter.c Avoid duplicates in ALTER ... DEPENDS ON EXTENSION 2020-03-11 11:04:59 -03:00
amcmds.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
analyze.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
async.c Refactor ps_status.c API 2020-03-11 16:38:31 +01:00
cluster.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
collationcmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
comment.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
constraint.c Fix bogus CALLED_AS_TRIGGER() defenses. 2020-04-03 11:24:56 -04:00
conversioncmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
copy.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
createas.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
dbcommands.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
define.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
discard.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
dropcmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
event_trigger.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
explain.c Include information on buffer usage during planning phase, in EXPLAIN output, take two. 2020-04-04 03:13:17 +09:00
extension.c Allow the planner-related functions and hook to accept the query string. 2020-03-30 13:51:05 +09:00
foreigncmds.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
functioncmds.c Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
indexcmds.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
lockcmds.c Make inherited LOCK TABLE perform access permission checks on parent table only. 2020-02-18 13:13:15 +09:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
matview.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
opclasscmds.c Improve error reporting in opclasscmds.c 2020-03-31 17:51:57 +03:00
operatorcmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
policy.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
portalcmds.c Allow the planner-related functions and hook to accept the query string. 2020-03-30 13:51:05 +09:00
prepare.c Include information on buffer usage during planning phase, in EXPLAIN output, take two. 2020-04-04 03:13:17 +09:00
proclang.c Remove the "opaque" pseudo-type and associated compatibility hacks. 2020-03-05 15:48:56 -05:00
publicationcmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
schemacmds.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
seclabel.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
sequence.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statscmds.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
subscriptioncmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
tablecmds.c Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
tablespace.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
trigger.c Enable BEFORE row-level triggers for partitioned tables 2020-03-18 18:58:05 -03:00
tsearchcmds.c Preserve integer and float values accurately in (de)serialize_deflist. 2020-03-10 12:30:02 -04:00
typecmds.c Split out CreateCast into src/backend/catalog/pg_cast.c 2020-03-10 11:28:23 -03:00
user.c Remove long-dead comments. 2020-02-12 14:33:49 -05:00
vacuum.c Fix coverity complaint about commit 40d964ec99. 2020-04-01 09:28:13 +05:30
variable.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
view.c Restructure ALTER TABLE execution to fix assorted bugs. 2020-01-15 18:49:24 -05:00