Re: Problem while setting the fpw with SIGHUP
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-03-13T08:04:04Z
Lists: pgsql-hackers
On Fri, Mar 09, 2018 at 01:42:04PM +0530, Dilip Kumar wrote:
> While setting the full_page_write with SIGHUP I hit an assert in checkpoint
> process. And, that is because inside a CRITICAL section we are calling
> RecoveryInProgress which intern allocates memory. So I have moved
> RecoveryInProgress call out of the CRITICAL section and the problem got
> solved.
Indeed, I can see how this is possible.
If you apply the following you can also have way more fun, but that's
overdoing it:
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7918,6 +7918,8 @@ CheckRecoveryConsistency(void)
bool
RecoveryInProgress(void)
{
+ Assert(CritSectionCount == 0);
Anyway, it seems to me that you are not taking care of all possible race
conditions here. RecoveryInProgress() could as well be called in
XLogFlush(), and that's a code path taken during redo.
Instead of doing what you are suggesting, why not moving
InitXLogInsert() out of InitXLOGAccess() and change InitPostgres() so as
the allocations for WAL inserts is done unconditionally? This has
the cost of also making this allocation even for backends which are
started during recovery, still we are talking about allocating a couple
of bytes in exchange of addressing completely all race conditions in
this area. InitXLogInsert() does not depend on any post-recovery data
like ThisTimeLineId, so a split is possible.
Thoughts?
--
Michael
Commits
-
Fix assertion failure when updating full_page_writes for checkpointer.
- 85cc9c4e2da8 9.5.15 landed
- e315bd7db96a 9.6.11 landed
- 8256d7ae9ee3 10.6 landed
- 6c8671bc395c 11.0 landed
- a86bf6057edf 12.0 landed
-
Attach FPI to the first record after full_page_writes is turned on.
- 47a589c1fe35 9.5.15 landed
- fd4f2af774db 9.6.11 landed
- ede7d8192ca3 10.6 landed
- ff4220ead2c8 11.0 landed
- bc153c941d2e 12.0 landed
-
Revamp the WAL record format.
- 2c03216d8311 9.5.0 cited
-
Move the backup-block logic from XLogInsert to a new file, xloginsert.c.
- 2076db2aea76 9.5.0 cited