| From: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Cc: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
| Subject: | [PATCH] vacuum: stop using stream ring after failsafe |
| Date: | 2026-07-22 16:52:57 |
| Message-ID: | CAPsk3_APRYVLhAJ5TMwdmpSx8W_=PHMm=PmKAvnC3gBrfNommQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| v1-0001-vacuum-stop-using-stream-ring-after-failsafe.patch | application/octet-stream | 4.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Andres Freund | 2026-07-22 16:24:48 | Re: [PATCH] Batched clock sweep to reduce cross-socket atomic contention |