Re: admin control over cancelling autovacuum when blocked by a lock - Mailing list pgsql-admin

From Rui DeSousa
Subject Re: admin control over cancelling autovacuum when blocked by a lock
Date
Msg-id CB30B39F-CE56-417A-8CFB-C23F07DD51B8@crazybean.net
Whole thread Raw
In response to Re: admin control over cancelling autovacuum when blocked by a lock  (John Lumby <johnlumby@hotmail.com>)
Responses Re: admin control over cancelling autovacuum when blocked by a lock  (John Lumby <johnlumby@hotmail.com>)
List pgsql-admin


On Apr 30, 2019, at 4:04 PM, John Lumby <johnlumby@hotmail.com> wrote:

surely the user would prefer that the 
ANALYZE would wait until after
the autovacuum has finished

Not really… analyze takes an exclusive lock; I believe.  The result is that readers/analyze will block other readers and writes which is bad for concurrency.  Readers should never be blocked :)… 

I had the follow problem occur; which I hope will illustrate why you wouldn’t what do what you are recommending. 

I explicitly do not allow the application to issue DDL including the analyze command against the base tables; however, developers are developers and they will try anything at least once.  The application was coded with an analyze command and the result was huge blocking issues.

1. Application issue analyze
2. Analyze waits on exclusive lock
3. As, there is already a long running query running against the table
4. New readers; get blocked and are now waiting behind the analyze command.
5. Writes are also blocked and waiting behind the analyze command.
6. Long running query completes.
7. Analyze command fails due to lack of permissions.
8. Application retries; rinse and repeat.

* The real response is we had to kill the session attempting to issue analyze and issue a hot fix otherwise the blocking would cause all sorts of application issues.  



pgsql-admin by date:

Previous
From: John Lumby
Date:
Subject: Re: admin control over cancelling autovacuum when blocked by a lock
Next
From: John Lumby
Date:
Subject: Re: admin control over cancelling autovacuum when blocked by a lock