mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Only clear VACUUM's read stream strategy once in failsafe mode
112c268380 restored failsafe vacuum's abandonment of a buffer
access strategy by clearing the ReadBuffersOperations' strategy
references. But it did so in lazy_scan_heap()'s main loop, meaning it
looped through all the ReadBuffersOperations once per block after
failsafe was engaged. Track it with a local flag and clear the strategy
only once.
Reported-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/CAAKRu_Zse14nSNeCgtnE1LUAH8Of7OmYR%2BCc3O_DAzxt3m6T-g%40mail.gmail.com
Backpatch-through: 18
This commit is contained in:
@@ -1206,6 +1206,7 @@ lazy_scan_heap(LVRelState *vacrel)
|
||||
BlockNumber orig_eager_scan_success_limit =
|
||||
vacrel->eager_scan_remaining_successes; /* for logging */
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
bool strategy_cleared = false;
|
||||
const int initprog_index[] = {
|
||||
PROGRESS_VACUUM_PHASE,
|
||||
PROGRESS_VACUUM_TOTAL_HEAP_BLKS,
|
||||
@@ -1311,10 +1312,14 @@ lazy_scan_heap(LVRelState *vacrel)
|
||||
* If the wraparound failsafe has engaged -- either via the check
|
||||
* above or during index vacuuming invoked from this loop -- stop
|
||||
* using the buffer access strategy so that the rest of the vacuum may
|
||||
* use all of shared buffers.
|
||||
* use all of shared buffers. Failsafe mode stays engaged once
|
||||
* triggered, so we only need to do this once.
|
||||
*/
|
||||
if (unlikely(VacuumFailsafeActive))
|
||||
if (unlikely(VacuumFailsafeActive) && !strategy_cleared)
|
||||
{
|
||||
read_stream_clear_strategy(stream);
|
||||
strategy_cleared = true;
|
||||
}
|
||||
|
||||
buf = read_stream_next_buffer(stream, &per_buffer_data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user