| From: | Adam Lee <adam8157(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | Amit Kapila <akapila(at)postgresql(dot)org> |
| Subject: | [PATCH] Avoid orphaning buffers when a relation's file is missing |
| Date: | 2026-06-09 09:55:04 |
| Message-ID: | aifizBXakKoiaAiA@MAC-CVW1VHW5R6 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Hit a case where the server can't checkpoint anymore, and it comes down to the
targeted-drop optimization in DropRelationsAllBuffers().
The scenario is disaster recovery: a relation's data file has gone missing
on disk (failed restore, lost/again-detached storage, a half-finished manual
cleanup, ...), and the administrator does the natural thing -- DROP the
broken relation to get the system going again. The catch is that a dirty
buffer for that relation can still be resident in shared buffers, and every
checkpoint after that fails trying to write it back:
could not open file "..." while writing block N of relation ...
Before bea449c635c the full scan always ran, so dropping the relation cleaned
the buffer up regardless of the file. The attached patch restores that for the
main fork only -- fsm/vm/init are routinely absent (a permanent rel never has
an init fork), so forcing a full scan on their absence would kill the
optimization for almost every drop.
No in-core reproducer since it needs the file to vanish underneath us, but the
path is clear once it does. Patch attached.
--
Adam
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Avoid-orphaning-buffers-when-a-relation-s-file-is-mi.patch | text/plain | 3.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-06-09 10:03:06 | Re: Subquery pull-up increases jointree search space |
| Previous Message | Andrei Lepikhov | 2026-06-09 09:51:07 | Show hashed SAOP decision in EXPLAIN |