pgsql: Handle wraparound during truncation in multixact/members - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: Handle wraparound during truncation in multixact/members
Date
Msg-id E1Vyq0X-0006dh-8N@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Handle wraparound during truncation in multixact/members

In pg_multixact/members, relying on modulo-2^32 arithmetic for
wraparound handling doesn't work all that well.  Because we don't
explicitely track wraparound of the allocation counter for members, it
is possible that the "live" area exceeds 2^31 entries; trying to remove
SLRU segments that are "old" according to the original logic might lead
to removal of segments still in use.  To fix, have the truncation
routine use a tailored SlruScanDirectory callback that keeps track of
the live area in actual use; that way, when the live range exceeds 2^31
entries, the oldest segments still live will not get removed untimely.

This new SlruScanDir callback needs to take care not to remove segments
that are "in the future": if new SLRU segments appear while the
truncation is ongoing, make sure we don't remove them.  This requires
examination of shared memory state to recheck for false positives, but
testing suggests that this doesn't cause a problem.  The original coding
didn't suffer from this pitfall because segments created when truncation
is running are never considered to be removable.

Per Andres Freund's investigation of bug #8673 reported by Serge
Negodyuck.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/722acf51a0d074d19782ad7e97ebe3fdb63fbb87

Modified Files
--------------
src/backend/access/transam/multixact.c |   90 ++++++++++++++++++++++++++++++--
src/backend/access/transam/slru.c      |   31 ++++++-----
src/include/access/slru.h              |    1 +
3 files changed, 104 insertions(+), 18 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Handle 5-char filenames in SlruScanDirectory
Next
From: Alvaro Herrera
Date:
Subject: pgsql: Handle wraparound during truncation in multixact/members