Bug in two-phase transaction recovery

From: Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Bug in two-phase transaction recovery
Date: 2016-09-07 13:48:53
Message-ID: 39DA46C9-9212-4CAF-AD4D-1C6FA91E1CA0@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

Some time ago two-phase state file format was changed to have variable size GID,
but several places that read that files were not updated to use new offsets. Problem
exists in master and 9.6 and can be reproduced on prepared transactions with
savepoints. For example:

create table t(id int);
begin;
insert into t values (42);
savepoint s1;
insert into t values (43);
prepare transaction 'x';
begin;
insert into t values (142);
savepoint s1;
insert into t values (143);
prepare transaction 'y’;

and restart the server. Startup process will hang. Fix attached.

Also while looking at StandbyRecoverPreparedTransactions() i’ve noticed that buffer
for 2pc file is allocated in TopMemoryContext but never freed. That probably exists
for a long time.

Attachment Content-Type Size
gidlen_fixes.diff application/octet-stream 1.1 KB
unknown_filename text/plain 3 bytes
standby_recover_pfree.diff application/octet-stream 433 bytes
unknown_filename text/plain 94 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Victor Wagner 2016-09-07 13:56:34 Re: Patch: Implement failover on libpq connect level.
Previous Message Tom Lane 2016-09-07 13:46:32 Re: Install extensions using update scripts (was Re: Remove superuser() checks from pgstattuple)