Re: Exposing the lock manager's WaitForLockers() to SQL

From: Will Mortensen <will(at)extrahop(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Marco Slot <marco(dot)slot(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, marco(at)citusdata(dot)com, Yvonne Chen <yvonne(at)extrahop(dot)com>, Jacob Speidel <jacob(at)extrahop(dot)com>
Subject: Re: Exposing the lock manager's WaitForLockers() to SQL
Date: 2023-12-23 09:47:40
Message-ID: CAMpnoC5igCPy2aBYtrcPwsp6Zz_=-cKBZH8Mkxk3v=yHL-_W-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Sep 3, 2023 at 11:16 PM Will Mortensen <will(at)extrahop(dot)com> wrote:
> I realized that for our use case, we'd ideally wait for holders of
> RowExclusiveLock only, and not e.g. VACUUM holding
> ShareUpdateExclusiveLock. Waiting for lockers in a specific mode seems
> possible by generalizing/duplicating WaitForLockersMultiple() and
> GetLockConflicts(), but I'd love to have a sanity check before
> attempting that. Also, I imagine those semantics might be too
> different to make sense as part of the LOCK command.

Well I attempted it. :-) Here is a new series that refactors
GetLockConflicts(), generalizes WaitForLockersMultiple(), and adds a
new WAIT FOR LOCKERS command.

I first tried extending LOCK further, but the code became somewhat
unwieldy and the syntax became very confusing. I also thought again
about making new pg_foo() functions, but that would seemingly make it
harder to share code with LOCK, and sharing syntax (to the extent it
makes sense) feels very natural. Also, a new SQL command provides
plenty of doc space. :-) (I'll see about adding more examples later.)

I'll try to edit the title of the CF entry accordingly. Still looking
forward to any feedback. :-)

Attachment Content-Type Size
v4-0002-Allow-specifying-single-lockmode-in-WaitForLocker.patch application/octet-stream 8.4 KB
v4-0003-Add-WAIT-FOR-LOCKERS-command.patch application/octet-stream 40.7 KB
v4-0001-Refactor-GetLockConflicts-into-more-general-GetLo.patch application/octet-stream 8.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Will Mortensen 2023-12-23 09:56:37 Re: Exposing the lock manager's WaitForLockers() to SQL
Previous Message Japin Li 2023-12-23 07:37:33 Re: Fixing pgbench init overflow