Re: Buffer locking is special (hints, checksums, AIO writes)
От | Robert Haas |
---|---|
Тема | Re: Buffer locking is special (hints, checksums, AIO writes) |
Дата | |
Msg-id | CA+TgmoYY=w7QGoVnnTLU5p+6jKoAJsOmbvSsgWOiFqSjZAwO3Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Buffer locking is special (hints, checksums, AIO writes) (Noah Misch <noah@leadboat.com>) |
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: