Graceful way to handle too many locks - Mailing list pgsql-hackers

From Chris Cleveland
Subject Graceful way to handle too many locks
Date
Msg-id CABSN6VdhP_arx6oZBOBQ0=LWzoX8iSOa6GipsJg3Usws6mZoUw@mail.gmail.com
Whole thread Raw
Responses Re: Graceful way to handle too many locks
Re: Graceful way to handle too many locks
List 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

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: schema variables
Next
From: Tomas Vondra
Date:
Subject: Re: Graceful way to handle too many locks