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.
--
Stas Kelvich
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company