Re: FSM Corruption (was: Could not read block at end of the relation)
Ronan Dunklau <ronan.dunklau@aiven.io>
From: Ronan Dunklau <ronan.dunklau@aiven.io>
To: Noah Misch <noah@leadboat.com>
Cc: Michael Paquier <michael@paquier.xyz>,
pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Date: 2024-04-11T07:36:50Z
Lists: pgsql-bugs
Le dimanche 7 avril 2024, 00:30:37 CEST Noah Misch a écrit : > Your v3 has the right functionality. As further confirmation of the fix, I > tried reverting the non-test parts of commit 917dc7d "Fix WAL-logging of FSM > and VM truncation". That commit's 008_fsm_truncation.pl fails with 917dc7d > reverted from master, and adding this patch makes it pass again. I ran > pgindent and edited comments. I think the attached version is ready to go. > Thank you Noah, the updated comments are much better. I think it should be backported at least to 16 since the chances of tripping on that behaviour are quite high here, but what about previous versions ? > While updating comments in FreeSpaceMapPrepareTruncateRel(), I entered a > rabbit hole about the comments 917dc7d left about torn pages. I'm sharing > these findings just in case it helps a reader of the $SUBJECT patch avoid > the same rabbit hole. Both fsm and vm read with RBM_ZERO_ON_ERROR, so I > think they're fine with torn pages. Per the README sentences I'm adding, > FSM could stop writing WAL. I'm not proposing that, but I do bet it's the > right thing. visibilitymap_prepare_truncate() has mirrored fsm truncate > since 917dc7d. The case for removing WAL there is clearer still, because > parallel function visibilitymap_clear() does not write WAL. I'm attaching > a WIP patch to remove visibilitymap_prepare_truncate() WAL. I'll abandon > that or pursue it for v18, in a different thread. That's an interesting finding. > If I were continuing the benchmark study, I would try SSD, a newer kernel, > and/or shared_buffers=48GB. Instead, since your perf results show only > +0.01% CPU from new lseek() calls, I'm going to stop there and say it's > worth taking the remaining risk that some realistic scenario gets a > material regression from those new lseek() calls. Agree with you here. Many thanks, -- Ronan Dunklau
Commits
-
freespace: Don't return blocks past the end of the main fork.
- 08059fc049ff 14.12 landed
- 7c490a18b75b 15.7 landed
- 4e62ba21a921 16.3 landed
- 935829743151 17.0 landed
-
Fix WAL-logging of FSM and VM truncation.
- 917dc7d2393c 10.0 cited
-
Extend relations multiple blocks at a time to improve scalability.
- 719c84c1be51 9.6.0 cited