Re: [HACKERS] Restricting maximum keep segments by repslots
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, jgdr@dalibo.com, michael@paquier.xyz, sawada.mshk@gmail.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, thomas.munro@enterprisedb.com, sk@zsrv.org, michael.paquier@gmail.com
Date: 2020-05-17T07:02:49Z
Lists: pgsql-hackers
On 2020-May-16, Andres Freund wrote: > Hi, > > On 2020-05-16 22:51:50 -0400, Alvaro Herrera wrote: > > On 2020-May-16, Andres Freund wrote: > > > > > I, independent of this patch, added a few additional paths in which > > > checkpointer's latch is reset, and I found a few shutdowns in regression > > > tests to be extremely slow / timing out. The reason for that is that > > > the only check for interrupts is at the top of the loop. So if > > > checkpointer gets SIGUSR2 we don't see ShutdownRequestPending until we > > > decide to do a checkpoint for other reasons. > > > > Ah, yeah, this seems a genuine bug. > > > > > I also suspect that it could have harmful consequences to not do a > > > AbsorbSyncRequests() if something "ate" the set latch. > > > > I traced through this when looking over the previous fix, and given that > > checkpoint execution itself calls AbsorbSyncRequests frequently, I > > don't think this one qualifies as a bug. > > There's no AbsorbSyncRequests() after CheckPointBuffers(), I think. And > e.g. CheckPointTwoPhase() could take a while. Which then would mean that > we'd potentially not AbsorbSyncRequests() until checkpoint_timeout > causes us to wake up. Am I missing something? True. There's no delay like CheckpointWriteDelay in that code though, so the "a while" is much smaller. My understanding of these sync requests is that they're not for immediate processing anyway -- I mean it's okay for checkpointer to take a bit of time before syncing ... or am I mistaken? (If another sync request is queued and the queue hasn't been emptied, that would set the latch again, so it's not like this could fill the queue arbitrarily.) > > > One way to do that would be to WaitLatch() call to much earlier, and > > > only do a WaitLatch() if do_checkpoint is false. Roughly like in the > > > attached. > > > > Hm. I'd do "WaitLatch() / continue" in the "!do_checkpoint" block, and > > put the checpkoint code not in the else block; seems easier to read to > > me. > > Yea, that'd probably be better. I was also pondering if we shouldn't > just move the checkpoint code into, gasp, it's own function ;) That might work :-) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Save slot's restart_lsn when invalidated due to size
- 12e52ba5a76e 13.0 landed
- 0188bb82531f 14.0 landed
-
Fix checkpoint signalling
- 1816a1c6ffe4 13.0 landed
-
Check slot->restart_lsn validity in a few more places
- d0abe78d8427 13.0 landed
-
Allow users to limit storage reserved by replication slots
- c6550776394e 13.0 landed
-
Remove header noise from test_decoding test
- 69360b34589b 13.0 landed
-
Rework WAL-reading supporting structs
- 709d003fbd98 13.0 cited
-
Flip argument order in XLogSegNoOffsetToRecPtr
- a22445ff0be2 12.0 cited