Re: postgres 9.4.5 - pg_serial not decreasing

From: Kevin Grittner <kgrittn(at)gmail(dot)com>
To: Alexandre Garcia <alexandre(at)vmfarms(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: postgres 9.4.5 - pg_serial not decreasing
Date: 2016-06-07 20:38:39
Message-ID: CACjxUsM920A-emaozVX9eaGWe--PG4ADb=REqp8RT4gKOp=dMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, Jun 7, 2016 at 3:24 PM, Alexandre Garcia <alexandre(at)vmfarms(dot)com> wrote:

> No old transactions are sitting in pg_stat_activity nor pg_prepared_xacts.
> But since it was few weeks ago, it might have been the case before.
> But that doesn't explain why that directory is still so big.

When the SERIALIZABLE transaction isolation level was upgraded to
truly serializable behavior in release 9.1, the committer at the
time insisted on leaving the files in the pg_serial directory on
shutdown and startup in case anyone wanted to dig through them for
debugging purposes -- they have no operational value across
restarts. If you reached wraparound because of a very old
transaction, the directory should slowly shrink again as
transaction IDs advance, and the safe thing to do (after confirming
this behavior) would be to just let that happen. Theoretically,
deleting the files in that directory WHILE THE DATABASE SERVICE IS
STOPPED should be safe, but I have never done that, and would not
recommend it unless the disk space issue is critical because of it
and you make a backup of the directory first. Direct modification
of any internal files like that should always be considered high
risk, and that risk carefully balanced against the expected
benefit.

Hopefully you can see a gap in the file numbers, and see that it is
expanding over time, and can just let the problem sort itself out.

You may want to add some sort of monitoring for old prepared
transactions and idle transactions to prevent a recurrence.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2016-06-07 21:40:51 Re: Planner is ignoring index when view is queried but uses index when running underlying view's sql
Previous Message Alexandre Garcia 2016-06-07 20:24:12 Re: postgres 9.4.5 - pg_serial not decreasing