Re: pg_stat_statements locking - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: pg_stat_statements locking
Date
Msg-id 33CA7956-7A42-4731-B4AD-0372B5E9F2DB@yandex-team.ru
Whole thread Raw
In response to Re: pg_stat_statements locking  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_stat_statements locking
List pgsql-hackers

> On 12 Sep 2022, at 23:01, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Andrey Borodin <x4mmm@yandex-team.ru> writes:
>>> On 12 Sep 2022, at 18:18, Julien Rouhaud <rjuju123@gmail.com> wrote:
>>> That being
>>> said I don't know if adding a timeout would be too expensive for the lwlock
>>> infrastructure.
>
> I want to object fiercely to loading down LWLock with anything like
> timeouts.  It's supposed to be "lightweight".  If we get away from
> that we're just going to find ourselves needing another lighter-weight
> lock mechanism.

Thanks for clarifying this out, Tom. I agree that spreading timeout-based algorithms is not a good thing. And when you
havea hammer - everything seems like a nail, so it would be temping to use timeout here and there. 


> On 12 Sep 2022, at 23:08, Julien Rouhaud <rjuju123@gmail.com> wrote:
>
> That's what I was thinking, so it looks like a show-stopper for the proposed
> patch.

So, the only option to make things configurable is a switch for waiting\waitless locks.

And the other way is refactoring towards partitioned hashtable, namely dshash. But I don't see how partitioned locking
cansave us from a locking disaster. Problem is caused by reading all the pgss view colliding with reset() or GC. Both
thisoperations deal with each partition - they will conflict anyway, with the same result. Time-consuming read of each
partitionwill prevent exclusive lock by reset(), and queued exclusive lock will prevent any reads from hashtable. 


Best regards, Andrey Borodin.


pgsql-hackers by date:

Previous
From: Marina Polyakova
Date:
Subject: Re: ICU for global collation
Next
From: Jaime Casanova
Date:
Subject: Re: START_REPLICATION SLOT causing a crash in an assert build