Re: could not truncate directory "pg_subtrans": apparent wraparound

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Dan Langille <dan(at)langille(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: could not truncate directory "pg_subtrans": apparent wraparound
Date: 2015-06-13 02:02:42
Message-ID: CAEepm=3z0EoLpo5wTUwseM38kbq+Gjp8xXiuLJkUqpM-SW7kAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

Since the multixact equivalent of this problem[1] fell through the
cracks on the multixact mega-thread, here is an updated patch that
addresses this problem for both pg_subtrans and pg_multixact/offsets
using the same approach: always step back one multixact/xid (rather
than doing so only if oldest == next, which seemed like an unnecessary
complication, and a bit futile since the result of such a test is only
an instantaneous snapshot). I've added this to the commitfest[2]. I
am also attaching a new set of repro scripts including a pair to test
the case where next multixact/xid == first valid ID (the scripts with
'wraparound' in the name, which use dirty pg_resetxlog tricks to get
into that situation). In my previous patch I naively subtracted one,
which didn't work for those (even rarer!) cases. The new patch steps
over the special ID values.

This is a low priority bug: it just produces low probability bogus
(but perhaps alarming) LOG messages and skips truncation during
checkpoints on low activity systems. There have been occasional
reports of these pg_subtrans messages going back as far as 2007 (and
Alvaro was barking up the correct tree[3] back in 2010), so I figured
it was worth following up.

I also took a look at the pg_clog and pg_commit_ts truncation
functions. You could argue that they have the same problem in theory
(they pass a page number derived from the oldest xid to
SimpleLruTruncate, and maybe there is a way for that to be an xid that
hasn't been issued yet), but in practice I don't think it's a
reachable condition. They use the frozen xid that is updated by
vacuuming, but vacuum itself advances the next xid counter in the
process. Is there a path though the vacuum code that ever exposes
frozen xid == next xid? In contrast, for pg_subtrans we use
GetOldestXmin(), which is equal to the next xid if there are no
running transactions, and for pg_multixact we use the oldest
multixact, which can be equal to the next multixact ID after a
wraparound vacuum because vacuum itself doesn't always consume
multixacts.

[1] http://www.postgresql.org/message-id/CAEepm=0DqAtnM=23OQ44BbnwvN3g6+DXx+s5g4JRBP-VY8gEwQ@mail.gmail.com
[2] https://commitfest.postgresql.org/5/265/
[3] http://www.postgresql.org/message-id/1274373980-sup-3414@alvh.no-ip.org

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

Attachment Content-Type Size
repro-bogus-multixact-error.sh application/x-sh 728 bytes
repro-bogus-subtrans-error.sh application/x-sh 438 bytes
repro-bogus-multixact-error-wraparound.sh application/x-sh 2.1 KB
repro-bogus-subtrans-error-wraparound.sh application/x-sh 1.2 KB
fix-bogus-truncation-errors.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2015-06-13 02:08:09 Re: Entities created in one query not available in another in extended protocol
Previous Message Bruce Momjian 2015-06-13 01:47:29 Re: 9.5 release notes