[PATCH] vacuum: stop using stream ring after failsafe - Mailing list pgsql-hackers

From Jingtang Zhang
Subject [PATCH] vacuum: stop using stream ring after failsafe
Date
Msg-id CAPsk3_APRYVLhAJ5TMwdmpSx8W_=PHMm=PmKAvnC3gBrfNommQ@mail.gmail.com
Whole thread
Responses Re: Fix SPLIT PARTITION bound-overlap bug and other improvements
List pgsql-hackers
Hi,

4830f1024325 made VACUUM's failsafe abandon its buffer access strategy
and use normal shared-buffer replacement.  Commit 9256822608f3 later
converted VACUUM's first phase to use streaming read I/O.

Was it an oversight in the read stream conversion that the stream is
initialized with VACUUM's strategy, but is not updated when failsafe
clears vacrel->bstrategy?  As a result, the active stream continues to
use the VACUUM ring for later heap reads.

This patch allows a read stream's strategy to be changed for future I/O.
VACUUM switches the active stream to a NULL strategy when failsafe
activates, without modifying in-flight I/O operations.

The stream calculates its pin limit and queue capacity when it is
created. It uses the original strategy.  This patch deliberately changes
only buffer replacement for future reads; it does not resize the stream.

I am unsure whether a generic strategy setter is the right interface.  A
new strategy must accommodate the stream's fixed maximum number of pins.

I tested this manually with a 600000-block unlogged table and a 256 kB
VACUUM buffer usage limit.  A second session advanced the XID counter
after VACUUM began scanning, causing the 4 GB periodic check to enter
failsafe mode.  On my test instance, without this patch, the table's
main fork retained exactly 32 buffers in pg_buffercache.  With this
patch, it retained 30665 buffers after failsafe activation.

---
Regards,
Jingtang

Attachment

pgsql-hackers by date:

Previous
From: Boris Mironov
Date:
Subject: Re: Yet another PG extension to support Gzip, LZ4, Zstd functions optimized for multi-megabyte documents
Next
From: Paul Kim
Date:
Subject: Re: Restore vacuum_delay_point() in GIN posting-tree leaf vacuum