Re: How to solve "too many Lwlocks taken"?

From: Andres Freund <andres(at)anarazel(dot)de>
To: "jacktby(at)gmail(dot)com" <jacktby(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: How to solve "too many Lwlocks taken"?
Date: 2023-02-07 18:17:42
Message-ID: 20230207181742.6qaimfgu4cprtndm@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-02-07 22:16:36 +0800, jacktby(at)gmail(dot)com wrote:
>
> I'm trying to write am table_am extension. But I get "too many Lwlocks taken" after I insert
> too many tuples. So I try to use UnLockBuffers() everywhere; but it still give me "too many Lwlocks taken",
> So how should I release All locks?

This indicates that you aren't actually releasing all the lwlocks. You can
inspect
static int num_held_lwlocks = 0;
static LWLockHandle held_lwlocks[MAX_SIMUL_LWLOCKS];
in a debugger to see which locks you didn't release.

You're currently starting multiple threads with questions a week. Could you at
least keep them in one thread?

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-02-07 18:27:25 Re: [PATCH] Make ON CONFLICT DO NOTHING and ON CONFLICT DO UPDATE consistent
Previous Message Jacob Champion 2023-02-07 18:16:17 Re: Can we let extensions change their dumped catalog schemas?