Re: pg_stat_statements locking

2022-09-13 Thread Julien Rouhaud
On Tue, Sep 13, 2022 at 10:38:13AM +0500, Andrey Borodin wrote: > > And the other way is refactoring towards partitioned hashtable, namely > dshash. But I don't see how partitioned locking can save us from a locking > disaster. Problem is caused by reading all the pgss view colliding with >

Re: pg_stat_statements locking

2022-09-12 Thread Andrey Borodin
> On 12 Sep 2022, at 23:01, Tom Lane wrote: > > Andrey Borodin writes: >>> On 12 Sep 2022, at 18:18, Julien Rouhaud 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

Re: pg_stat_statements locking

2022-09-12 Thread Julien Rouhaud
On Mon, Sep 12, 2022 at 02:01:23PM -0400, Tom Lane wrote: > Andrey Borodin writes: > >> On 12 Sep 2022, at 18:18, Julien Rouhaud 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

Re: pg_stat_statements locking

2022-09-12 Thread Tom Lane
Andrey Borodin writes: >> On 12 Sep 2022, at 18:18, Julien Rouhaud 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

Re: pg_stat_statements locking

2022-09-12 Thread Andrey Borodin
> On 12 Sep 2022, at 18:18, Julien Rouhaud wrote: > > That being > said I don't know if adding a timeout would be too expensive for the lwlock > infrastructure. Implementation itself is straightforward, but we need to add 3 impls of waiting for semaphore with timeout. POSIX have

Re: pg_stat_statements locking

2022-09-12 Thread Julien Rouhaud
On Mon, Sep 12, 2022 at 05:32:55PM +0500, Andrey Borodin wrote: > > > On 12 Sep 2022, at 13:40, Julien Rouhaud 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

Re: pg_stat_statements locking

2022-09-12 Thread Andrey Borodin
> On 12 Sep 2022, at 13:40, Julien Rouhaud 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

Re: pg_stat_statements locking

2022-09-12 Thread Julien Rouhaud
Hi, On Mon, Sep 12, 2022 at 11:52:28AM +0500, Andrey Borodin wrote: > > === How to fix === > pgss uses LWLock to protect hashtable. > When the hashtable is reset or new user query is inserted in pgss_store() - > exclusive lock is used. > When stats are updated for known query or

pg_stat_statements locking

2022-09-12 Thread Andrey Borodin
Hi hackers! Recently I observed very peculiar incident. === Incident description === ETL database was operating fine for many months, regularly updated etc. Workload was not changing much, but as far as it was ETL database - most of queries were different all the time. On the night of