Re: admin control over cancelling autovacuum when blocked by a lock

From: Rui DeSousa <rui(at)crazybean(dot)net>
To: John Lumby <johnlumby(at)hotmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: admin control over cancelling autovacuum when blocked by a lock
Date: 2019-04-30 20:34:06
Message-ID: CB30B39F-CE56-417A-8CFB-C23F07DD51B8@crazybean.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> On Apr 30, 2019, at 4:04 PM, John Lumby <johnlumby(at)hotmail(dot)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.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message John Lumby 2019-04-30 20:46:33 Re: admin control over cancelling autovacuum when blocked by a lock
Previous Message John Lumby 2019-04-30 20:04:02 Re: admin control over cancelling autovacuum when blocked by a lock