Graceful way to handle too many locks

From: Chris Cleveland <ccleveland(at)dieselpoint(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Graceful way to handle too many locks
Date: 2024-11-13 19:05:15
Message-ID: CABSN6VdhP_arx6oZBOBQ0=LWzoX8iSOa6GipsJg3Usws6mZoUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In my extension I got a mystery error:

TRAP: failed Assert("InterruptHoldoffCount > 0"), File: "lwlock.c", Line:
1869, PID: 62663
0 postgres 0x000000010135adb4 ExceptionalCondition + 108
1 postgres 0x00000001012235ec LWLockRelease + 1456
2 postgres 0x00000001011faebc UnlockReleaseBuffer + 24

Turns out there was a bug in my extension where I was getting a share lock
on a particular index page over and over. Oddly, the error showed up not
when I was getting the locks, but when I released them. Any time I locked
the index page more than ~200 times, this error would show up on release.

Questions:

1. Why is the limit on the number of locks so low? I thought that when
getting a share lock, all it did was bump a reference count.

2. Is there a way to get this to fail gracefully, that is, with an error
message that makes sense, and kicks in at the moment you go over the limit,
instead of later?

--
Chris Cleveland
312-339-2677 mobile

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-11-13 19:51:45 Re: Graceful way to handle too many locks
Previous Message Pavel Stehule 2024-11-13 18:18:40 Re: proposal: schema variables