Re: Buffer locking is special (hints, checksums, AIO writes)
Robert Haas <robertmhaas@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Require share-exclusive lock to set hint bits and to flush
- 82467f627bd4 19 (unreleased) landed
-
lwlock: Remove ForEachLWLockHeldByMe
- 55fbfb738b00 19 (unreleased) landed
-
bufmgr: Implement buffer content locks independently of lwlocks
- fcb9c977aa5f 19 (unreleased) landed
-
bufmgr: Change BufferDesc.state to be a 64-bit atomic
- dac328c8a682 19 (unreleased) landed
-
heapam: Add batch mode mvcc check and use it in page mode
- 0b96e734c590 19 (unreleased) landed
-
freespace: Don't modify page without any lock
- 45f658dacb9c 19 (unreleased) landed
-
heapam: Move logic to handle HEAP_MOVED into a helper function
- 548de59d93d5 19 (unreleased) landed
-
bufmgr: Optimize & harmonize LockBufHdr(), LWLockWaitListLock()
- 09ae2c8bac8d 19 (unreleased) landed
-
bufmgr: Add one-entry cache for private refcount
- 30df61990c67 19 (unreleased) landed
-
bufmgr: Separate keys for private refcount infrastructure
- edbaaea0a95e 19 (unreleased) landed
-
Add pg_atomic_unlocked_write_u64
- 7902a47c20b1 19 (unreleased) landed
-
Rename BUFFERPIN wait event class to BUFFER
- 6c5c393b7403 19 (unreleased) landed
-
bufmgr: Turn BUFFER_LOCK_* into an enum
- 156680055dc5 19 (unreleased) landed
-
lwlock: Fix, currently harmless, bug in LWLockWakeup()
- 81f773895321 19 (unreleased) landed
- da3971496531 15.16 landed
- 89c8a1b9069f 16.12 landed
- 427e886a79a5 17.8 landed
- 332693e75969 14.21 landed
- 8082b759d9b5 18.2 landed
-
bufmgr: Use atomic sub for unpinning buffers
- 5310fac6e0fc 19 (unreleased) landed
-
bufmgr: Allow some buffer state modifications while holding header lock
- c75ebc657ffc 19 (unreleased) landed
-
bufmgr: Fix valgrind checking for buffers pinned in StrategyGetBuffer()
- c819d1017ddb 19 (unreleased) landed
-
bufmgr: Don't lock buffer header in StrategyGetBuffer()
- 5e8998592879 19 (unreleased) landed
-
bufmgr: fewer calls to BufferDescriptorGetContentLock
- 3baae90013df 19 (unreleased) landed
-
bufmgr: Fix signedness of mask variable in BufferSync()
- 2a2e1b470b9b 19 (unreleased) landed
-
bufmgr: Introduce FlushUnlockedBuffer
- 3c2b97b29ee3 19 (unreleased) landed
-
Improve ReadRecentBuffer() scalability
- 819dc118c0f6 19 (unreleased) landed
On Tue, Aug 26, 2025 at 8:14 PM Noah Misch <noah@leadboat.com> wrote: > > > AFAIK "share exclusive" or "SX" is standard terminology. > > Can you say more about that? Looks like I was misremembering. I was thinking of Gray & Reuter, Transaction Processing: Concepts and Techniques, 1993. However, opening it up, I find that his vocabulary is slightly different. He offers the following six lock modes: IS, IX, S, SIX, Update, X. "I" means "intent" and acts as a modifier to the letter that follows. Hence, SIX means "a course-granularity shared lock with intent to set finer-granularity exclusive locks" (p. 408). His lock manager is hierarchical, so taking a SIX lock on a table means that you are allowed to read all the rows in the table and you are allowed to exclusive-lock individual rows as desired and nobody is allowed to exclusive-lock any rows in the table. It is compatible only with IS; that is, it does not preclude other people from share-locking individual rows (which might delay your exclusive locks on those rows). Since we don't have intent-locking in PostgreSQL, I think my brain mentally flattened this hierarchy down to S, X, SX, but that's not what he actually wrote. His "Update" locks are also somewhat interesting: an update lock is exactly like an exclusive lock except that it permits PAST share-locks. You take an update lock when you currently need a share-lock but anticipate the possibility of needing an exclusive-lock. This is a deadlock avoidance strategy: updaters will take turns, and some of them will ultimately want exclusive locks and others won't, but they can't deadlock against each other as long as they all take "Update" locks initially and don't try to upgrade to that level later. An updater's attempt to upgrade to an exclusive lock can still be delayed by, or deadlock against, share lockers, but those typically won't try to higher lock levels later. If we were to use the existing PostgreSQL naming convention, I think I'd probably argue that the nearest parallel to this level is ShareUpdateExclusive: a self-exclusive lock level that permits ordinary table access to continue while blocking exclusive locks, used for an in-flight maintenance operation. But that's arguable, of course. -- Robert Haas EDB: http://www.enterprisedb.com