Re: pg_stat_statements locking - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: pg_stat_statements locking
Date
Msg-id CBE9E90B-6987-4B83-B169-E0E3BFE3A70C@yandex-team.ru
Whole thread Raw
In response to Re: pg_stat_statements locking  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: pg_stat_statements locking
List pgsql-hackers

> On 12 Sep 2022, at 13:40, Julien Rouhaud <rjuju123@gmail.com> wrote:
>
> I'm not a fan of that patch as it now silently ignores entries if the lwlock
> can't be acquired *immediately*, without any way to avoid that if your
> configuration and/or workload doesn't lead to this problem, or any way to know
> that entries were ignored.

Practically, workload of this configuration is uncommon. At least I could not find any reports of such locking.
But theoretically, all prerequisites of a disaster is very common (variety of queries + some QPS of pg_stat_statements
view+ small work_mem + occasional reset() or GC). 

Maybe it's only a problem of programs that use pgss. pgwatch is calling pgss on every DB in the cluster, that's how
checkonce in a minute became some queries per second. 

Personally, I'd prefer if I could configure a timeout to aquire lock. That timeout would denote maximum delay that pgss
canincur on the query. But we would need to extend LWLock API for this. 



> On 12 Sep 2022, at 13:40, Julien Rouhaud <rjuju123@gmail.com> wrote:
>
> I think that the better long term approach is to move pg_stat_statements and
> the query texts to dynamic shared memory.

BTW we don't even need a dynamic memory. We need just a shared memory, probably pre-allocated.
I agree that pgss must reside in main memory only, never on disk.

But we still will have a possibility of long lock conflicts preventing queries from completing. And the ability to
configurepgss hooks timeout would be useful anyway. 


Best regards, Andrey Borodin.


pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Assertion failure in WaitForWALToBecomeAvailable state machine
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: possibility to read dumped table's name from file