Re: BUG #15346: Replica fails to start after the crash
Alexander Kukushkin <cyberdemn@gmail.com>
From: Alexander Kukushkin <cyberdemn@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Dmitry Dolgov <9erthalion6@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2018-08-23T10:06:59Z
Lists: pgsql-bugs, pgsql-hackers
Hi,
I think I am getting closer:
If I start postgres without background worker, then works following code:
// https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/nbtree/nbtxlog.c;h=c536e224321dbc46574aa76876b9d49fa4b5e9a4;hb=REL9_6_10#l549
if (CountDBBackends(InvalidOid) == 0)
return latestRemovedXid;
And it returns from the btree_xlog_delete_get_latestRemovedXid function.
In case if we have a background worker, then
CountDBBackends(InvalidOid) = 1 and as a result it aborts.
Comment before if statement clearly tells about possible race condition:
/*
* If there's nothing running on the standby we don't need to derive a
* full latestRemovedXid value, so use a fast path out of here. This
* returns InvalidTransactionId, and so will conflict with all HS
* transactions; but since we just worked out that that's zero people,
* it's OK.
*
* XXX There is a race condition here, which is that a new backend might
* start just after we look. If so, it cannot need to
conflict, but this
* coding will result in throwing a conflict anyway.
*/
Regards,
--
Alexander Kukushkin
Commits
-
Ensure correct minimum consistent point on standbys
- 65f39408ee71 9.3.25 landed
- d9638a326f72 9.4.20 landed
- f3520ff6fbf1 9.5.15 landed
- 4a9a5bb3fd2a 9.6.11 landed
- 2c8cff5dd60b 10.6 landed
- c34f8078aa35 11.0 landed
- c186ba135eca 12.0 landed
-
Prevent references to invalid relation pages after fresh promotion
- 8d68ee6f31ca 9.6.10 cited