Thread: pgsql: Add code to prevent transaction ID wraparound by enforcing a safe

pgsql: Add code to prevent transaction ID wraparound by enforcing a safe

From
tgl@svr1.postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Add code to prevent transaction ID wraparound by enforcing a safe limit
in GetNewTransactionId().  Since the limit value has to be computed
before we run any real transactions, this requires adding code to database
startup to scan pg_database and determine the oldest datfrozenxid.
This can conveniently be combined with the first stage of an attack on
the problem that the 'flat file' copies of pg_shadow and pg_group are
not properly updated during WAL recovery.  The code I've added to
startup resides in a new file src/backend/utils/init/flatfiles.c, and
it is responsible for rewriting the flat files as well as initializing
the XID wraparound limit value.  This will eventually allow us to get
rid of GetRawDatabaseInfo too, but we'll need an initdb so we can add
a trigger to pg_database.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        maintenance.sgml (r1.40 -> r1.41)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/maintenance.sgml.diff?r1=1.40&r2=1.41)
    pgsql/src/backend/access/transam:
        varsup.c (r1.60 -> r1.61)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/varsup.c.diff?r1=1.60&r2=1.61)
        xact.c (r1.195 -> r1.196)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c.diff?r1=1.195&r2=1.196)
    pgsql/src/backend/bootstrap:
        bootstrap.c (r1.198 -> r1.199)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/bootstrap/bootstrap.c.diff?r1=1.198&r2=1.199)
    pgsql/src/backend/commands:
        dbcommands.c (r1.149 -> r1.150)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/dbcommands.c.diff?r1=1.149&r2=1.150)
        user.c (r1.148 -> r1.149)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/user.c.diff?r1=1.148&r2=1.149)
        vacuum.c (r1.300 -> r1.301)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/vacuum.c.diff?r1=1.300&r2=1.301)
    pgsql/src/backend/libpq:
        hba.c (r1.137 -> r1.138)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/libpq/hba.c.diff?r1=1.137&r2=1.138)
    pgsql/src/backend/postmaster:
        postmaster.c (r1.443 -> r1.444)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/postmaster/postmaster.c.diff?r1=1.443&r2=1.444)
    pgsql/src/backend/tcop:
        postgres.c (r1.440 -> r1.441)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/postgres.c.diff?r1=1.440&r2=1.441)
    pgsql/src/backend/utils/init:
        Makefile (r1.17 -> r1.18)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/Makefile.diff?r1=1.17&r2=1.18)
    pgsql/src/include/access:
        transam.h (r1.51 -> r1.52)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/access/transam.h.diff?r1=1.51&r2=1.52)
    pgsql/src/include/commands:
        user.h (r1.25 -> r1.26)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/user.h.diff?r1=1.25&r2=1.26)

Added Files:
-----------
    pgsql/src/backend/utils/init:
        flatfiles.c (r1.1)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/flatfiles.c?rev=1.1&content-type=text/x-cvsweb-markup)
    pgsql/src/include/utils:
        flatfiles.h (r1.1)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/flatfiles.h?rev=1.1&content-type=text/x-cvsweb-markup)