Re: Is this a problem in GenericXLogFinish()?
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers@postgresql.org
Date: 2023-09-27T15:47:04Z
Lists: pgsql-hackers
On Wed, Sep 27, 2023 at 11:03 AM Jeff Davis <pgsql@j-davis.com> wrote: > So it looks like it's intentionally registering a clean buffer so that > it can take a cleanup lock for reasons other than cleaning (or even > modiying) the page. I would think that there's a better way of > accomplishing that goal, so perhaps we can fix that? I had forgotten some of the details of how this works until you reminded me, but now that you've jarred my memory, I remember some of it. When Amit Kaplla and I were working on the project to add WAL-logging to hash indexes, we ran into some problems with concurrency control for individual buckets within the hash index. Before that project, this was handled using heavyweight locks, one per bucket. That got changed in 6d46f4783efe457f74816a75173eb23ed8930020 for the reasons explained in that commit message. Basically, instead of taking heavyweight locks, we started taking cleanup locks on the primary bucket pages. I always thought that was a little awkward, but I didn't quite see how to do better. I don't think that I gave much thought at the time to the consequence you've uncovered here, namely that it means we're sometimes locking one page (the primary bucket page) because we want to do something to another bucket page (some page in the linked list of pages that are part of that bucket) and for that to be safe, we need to lock out concurrent scans of that bucket. I guess I don't know of any easy fix here. :-( -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Fix inconsistency with replay of hash squeeze record for clean buffers
- f56a9def71bb 17.0 landed
-
Set LSN for wbuf in _hash_freeovflpage() iff wbuf is modified.
- aa5edbe379d6 17.0 landed
-
Fix an uninitialized access in hash_xlog_squeeze_page().
- f66fcc5cd616 17.0 landed
-
Use REGBUF_NO_CHANGE at one more place in the hash index.
- 861f86beea1c 17.0 landed
-
Assert that buffers are marked dirty before XLogRegisterBuffer().
- 00d7fb5e2e39 17.0 landed
-
Fix bug in GenericXLogFinish().
- 04f0baa85865 11.22 landed
- 6dbd01b9fdad 12.17 landed
- 469d367bee2f 13.13 landed
- 6615bb95af2d 14.10 landed
- b9bb02620d4b 15.5 landed
- b8963e8a2854 16.1 landed
- ef74c7197c04 17.0 landed
-
Improve hash index bucket split behavior.
- 6d46f4783efe 10.0 cited