From: David Waller <dwaller@yammer-inc.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14237: Terrible performance after accidentally running 'drop index' for index still being created
Date: Mon, 11 Jul 2016 16:42:27 +0000
Message-ID: <6A9A127D-FE6F-422D-BE82-B8154757367F@microsoft.com> (raw)
In-Reply-To: <11675.1467990502@sss.pgh.pa.us>
References: <20160708102407.1409.87848@wrigleys.postgresql.org>
<11675.1467990502@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 08/07/2016, 16:08, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:
> dwaller@microsoft.com writes:
> > Summary: While running ‘create index concurrently’ on a very large table,
> > running ‘drop index’ for the same index caused Postgres to perform terribly
> > badly, until the ‘create index’ server process was killed. I would expect
> > that the ‘drop index’ would either fail immediately, or wait, without
> > performance impact, until the ‘create index concurrently’ had completed.
>
> Hmm, the DROP INDEX should have blocked waiting for an exclusive lock on
> the table, and then other queries on the table should have queued up
> behind that lock request. I think the fact that they didn't just stop
> dead probably indicates that when the deadlock checker ran, it concluded
> it needed to let them jump the queue and go in front of the DROP INDEX to
> avoid a deadlock --- likely because the lock manager could see that the
> DROP was blocked by the CREATE INDEX CONCURRENTLY while the latter was
> waiting for the other queries to finish. So your slowdown corresponds to
> an extra wait of deadlock_timeout ms per query. This is not a bug, but
> designed behavior.
>
> > I would expect that running ‘drop index’ while that index is still being
> > created would either fail immediately, or wait, without performance impact,
> > until the ‘create index concurrently’ had completed.
>
> If the DROP's lock request is not allowed to block other incoming requests
> for a table lock, the DROP could face indefinite lock starvation. That is
> not better. Reducing deadlock_timeout to zero is not going to improve
> your overall performance, either.
Thank you for the detailed explanation. This all seems very sensible, and
reasonable behaviour from Postgres. Yet... it still 'allowed' me to shoot myself
painfully in the foot. User error, I agree, yet people make mistakes - could
Postgres behave more gracefully?
For example, would it be at all feasible for Postgres to handle DDL statements
differently from regular requests? In this example it was pointless for DROP
INDEX to take any locks while there was already another DDL statement (CREATE
INDEX) running. Could it have been added to a queue of DDL statements against
that table and not attempted to take a lock until CREATE INDEX completed and
DROP INDEX then reached the head of the queue?
Thanks,
David
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: dwaller@yammer-inc.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #14237: Terrible performance after accidentally running 'drop index' for index still being created
In-Reply-To: <6A9A127D-FE6F-422D-BE82-B8154757367F@microsoft.com>
References: <20160708102407.1409.87848@wrigleys.postgresql.org> <11675.1467990502@sss.pgh.pa.us> <6A9A127D-FE6F-422D-BE82-B8154757367F@microsoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox