Small race in pg_xlogdump --follow

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Small race in pg_xlogdump --follow
Date: 2016-09-26 13:37:38
Message-ID: CABUevEyHuA=v+xPsvkXmPSVCbJn86Gz7P-zPfWa6Z1FBieevoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When using pg_xlogdump in --follow mode, there is what I believe is a small
race condition when files are switched.

If pg_xlogdump detects then end of one file (by looking at the record) it
will immediately try to open the following file. If that file has not yet
been created, it will fail with an error message saying it cannot open the
file. But there's a race condition where the server has not had time to put
the file in place.

Attached patch puts a retry loop around opening the file that retries for 5
seconds (which is excessive, but should be safe) in case the file is
missing (and still fails out for other error messages of course).

Comments?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
pg_xlogdump_race.patch text/x-patch 1.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-09-26 13:44:18 Re: Small race in pg_xlogdump --follow
Previous Message Tom Lane 2016-09-26 13:33:31 Re: VACUUM's ancillary tasks