From: | James Coleman <jtc331(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Idea: lock_timeout scoped by lock types |
Date: | 2025-01-29 19:54:06 |
Message-ID: | CAAaqYe_g_+dsTtkbR=BDLduih9587C7iF1zOXZyq4oDNgTKXLw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
We've put a lot of effort (as I know many others have) into ensuring
any DDL we run in production doesn't block (or, at least, doesn't
block for more than a very short amount of time). That includes the
obvious: e.g., don't do operations that require rewriting or scanning
a large table under an exclusive lock. Another key piece is relying on
a small lock_timeout value to ensure that when we do take out
exclusive locks we don't cause a large amount of queuing by having the
AccessExclusiveLock acquisition itself queued behind a long-running
query.
In our normal use setting lock_timeout happens inside libraries so we
don't have to think about it, but occasionally we have a use case that
isn't using those libraries, and that creates a foot-gun for us.
The obvious question would be: why not just set lock_timeout globally?
In practice that's not necessarily reasonable because it applies
equally to all lock types. A couple of examples:
- Table level: SELECTs or UPDATEs queue on a short-lived exclusive
lock: we don't want to timeout lock acquisition on these at all.
- Row level: we want to allow updates to the same rows (e.g.,
different columns, non conflicting) to execute sequentially without a
lock timeout.
But we don't want to allow reads or writes to queue for more than a
few seconds behind AccessExclusiveLock or even ShareLock.
I'm wondering if adding the ability to configure lock_timeout at a
more granular level is something that would be a reasonable solution
to this problem, or if folks think there's a better way to solve the
problem.
Regards,
James Coleman
From | Date | Subject | |
---|---|---|---|
Next Message | Corey Huinker | 2025-01-29 19:56:33 | Re: Extended Statistics set/restore/clear functions. |
Previous Message | Melanie Plageman | 2025-01-29 19:12:52 | Re: Eagerly scan all-visible pages to amortize aggressive vacuum |