Re: btree vacuum and suspended scans can deadlock

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: btree vacuum and suspended scans can deadlock
Date: 2016-10-14 03:22:52
Message-ID: CAA4eK1Lo76jTGFeXL6c7xU8juxxh2TWd8A74nfW3F2VN-GquLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 14, 2016 at 2:52 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Thu, Oct 13, 2016 at 6:33 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> If we agree that above is a problematic case, then some of the options
>> to solve it could be (a) Vacuum should not wait for a cleanup lock and
>> instead just give up and start again which I think is a bad idea (b)
>> don't allow to take lock of higher granularity after the scan is
>> suspended, not sure if that is feasible (c) document the above danger,
>> this sounds okay on the ground that nobody has reported the problem
>> till now
>
> I don't think any of these sound particularly good.
>

Tom has suggested something similar to approach (b) in his mail [1],
basically rejecting some commands like Truncate, Reindex,.. if the
current transaction is already holding the table open and I think if
we want to go that way, it might be better to reject any command that
requires lock level higher than the current transaction has on table.
Tom has suggested few more ways to resolve such deadlocks in that
thread, but I think we never implemented those.

Here, one point to think is do we really need to invent some ways to
make hash indexes not prone to that problem when it can occur for
other indexes or even for heap. Even if want to do something, I think
the solution has to be common.

[1] - https://www.postgresql.org/message-id/21534.1200956464@sss.pgh.pa.us

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2016-10-14 04:05:57 Minor improvement to delete.sgml
Previous Message Michael Paquier 2016-10-14 03:21:02 Re: Reporting wait events for system processes