Re: [HACKERS] pg_serial early wraparound - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: [HACKERS] pg_serial early wraparound
Date
Msg-id CAEepm=1PXuN_U00fYUASNscjc7F9GEos2qGDEHGvVeYGDkLV_A@mail.gmail.com
Whole thread Raw
In response to pg_serial early wraparound  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: [HACKERS] pg_serial early wraparound
List pgsql-hackers
On Wed, Nov 9, 2016 at 11:07 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> The SLRU managed by predicate.c can wrap around and overwrite data if
> you have more than 1 billion active XIDs.  That's because when SSI was
> implemented, slru.c was limited to four digit segment names, which
> implied a page limit that wasn't enough for pg_serial to have space
> for every possible XID.  We should probably rip that code out, because
> SLRUs now support five digit segment names.  Something like the
> attached.  I'll post a test script to demonstrate correct wraparound
> behaviour around in time for one of the later CFs.

Here is a shell script that shows a full rotation through xid space if
you build PostgreSQL with TEST_OLDSERXID, which you can do by
uncommenting a line in predicate.c.  On master we see the SLRU
segments go around the clock twice for each time xid goes around.
With the patch it goes around just once, adding an extra character to
the segment name to double the space.

By the way, I think the real number of xids it can hold today is
(65536 * 32 * 8192) / sizeof(uint64) = 2^31 xids, not 2^30 as
indicated by an existing comment.  So I think there is actually enough
space and wrapping is probably harmess, but it seems cleaner and
simpler not to do that and to rip out the scary warning code, so I'll
add this to the CF.

-- 
Thomas Munro
http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Beena Emerson
Date:
Subject: Re: [HACKERS] increasing the default WAL segment size
Next
From: Thomas Munro
Date:
Subject: Re: [HACKERS] pg_serial early wraparound