postgresql/src/backend
Andres Freund 4f1b890b13 Merge the various forms of transaction commit & abort records.
Since 465883b0a two versions of commit records have existed. A compact
version that was used when no cache invalidations, smgr unlinks and
similar were needed, and a full version that could deal with all
that. Additionally the full version was embedded into twophase commit
records.

That resulted in a measurable reduction in the size of the logged WAL in
some workloads. But more recently additions like logical decoding, which
e.g. needs information about the database something was executed on,
made it applicable in fewer situations. The static split generally made
it hard to expand the commit record, because concerns over the size made
it hard to add anything to the compact version.

Additionally it's not particularly pretty to have twophase.c insert
RM_XACT records.

Rejigger things so that the commit and abort records only have one form
each, including the twophase equivalents. The presence of the various
optional (in the sense of not being in every record) pieces is indicated
by a bits in the 'xinfo' flag.  That flag previously was not included in
compact commit records. To prevent an increase in size due to its
presence, it's only included if necessary; signalled by a bit in the
xl_info bits available for xact.c, similar to heapam.c's
XLOG_HEAP_OPMASK/XLOG_HEAP_INIT_PAGE.

Twophase commit/aborts are now the same as their normal
counterparts. The original transaction's xid is included in an optional
data field.

This means that commit records generally are smaller, except in the case
of a transaction with subtransactions, but no other special cases; the
increase there is four bytes, which seems acceptable given that the more
common case of not having subtransactions shrank.  The savings are
especially measurable for twophase commits, which previously always used
the full version; but will in practice only infrequently have required
that.

The motivation for this work are not the space savings and and
deduplication though; it's that it makes it easier to extend commit
records with additional information. That's just a few lines of code
now; without impacting the common case where that information is not
needed.

Discussion: 20150220152150.GD4149@awork2.anarazel.de,
    235610.92468.qm%40web29004.mail.ird.yahoo.com

Reviewed-By: Heikki Linnakangas, Simon Riggs
2015-03-15 17:37:07 +01:00
..
access Merge the various forms of transaction commit & abort records. 2015-03-15 17:37:07 +01:00
bootstrap Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
catalog Support default ACLs in get_object_address 2015-03-11 19:23:47 -03:00
commands Support default ACLs in get_object_address 2015-03-11 19:23:47 -03:00
executor Ensure tableoid reads correctly in EvalPlanQual-manufactured tuples. 2015-03-12 13:39:09 -04:00
foreign Update copyright for 2015 2015-01-06 11:43:47 -05:00
lib Fix a bug in pairing heap removal code. 2015-02-17 22:55:53 +02:00
libpq Use FLEXIBLE_ARRAY_MEMBER in a number of other places. 2015-02-21 16:12:14 -05:00
main Don't require users of src/port/gettimeofday.c to initialize it. 2015-02-21 12:17:04 -05:00
nodes Support flattening of empty-FROM subqueries and one-row VALUES tables. 2015-03-11 23:18:03 -04:00
optimizer Support flattening of empty-FROM subqueries and one-row VALUES tables. 2015-03-11 23:18:03 -04:00
parser Require non-NULL pstate for all addRangeTableEntryFor* functions. 2015-03-11 15:26:43 -04:00
po Translation updates 2015-02-01 23:23:40 -05:00
port Remove the option to service interrupts during PGSemaphoreLock(). 2015-02-03 23:25:00 +01:00
postmaster Add macros wrapping all usage of gcc's __attribute__. 2015-03-11 14:30:01 +01:00
regex Replace a bunch more uses of strncpy() with safer coding. 2015-01-24 13:05:42 -05:00
replication Merge the various forms of transaction commit & abort records. 2015-03-15 17:37:07 +01:00
rewrite Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
snowball Update copyright for 2015 2015-01-06 11:43:47 -05:00
storage Guard against spurious signals in LockBufferForCleanup. 2015-02-23 16:14:14 +01:00
tcop Code cleanup for REINDEX DATABASE/SCHEMA/SYSTEM. 2015-03-08 12:18:43 -04:00
tsearch Update copyright for 2015 2015-01-06 11:43:47 -05:00
utils Increase max_wal_size's default from 128MB to 1GB. 2015-03-15 17:37:07 +01:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
nls.mk Translation updates 2015-02-01 23:23:40 -05:00