Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7) - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)
Date
Msg-id CAPpHfdvws2_cCqsZOB14j253saCH-B33Yy0saYEQsAUsXu6xFA@mail.gmail.com
Whole thread Raw
In response to Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
Responses Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)
Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)
List pgsql-hackers
On Sun, Sep 29, 2019 at 5:38 PM Alexander Korotkov
<a.korotkov@postgrespro.ru> wrote:
> On Sun, Sep 29, 2019 at 11:17 AM chenhj <chjischj@163.com> wrote:
> > Does the locking order of autovacuum process(root->right->left) correct? While insert process lock gin buffer by
orderof bottom->top and left->right.
 
> >
> > 1. vacuum(root->right->left):
>
> Starting from root seems OK for me, because vacuum blocks all
> concurrent inserts before doing this.  But this needs to be properly
> documented in readme.
>
> Locking from right to left is clearly wrong.  It could deadlock with
> concurrent ginStepRight(), which locks from left to right.  I expect
> this happened in your case.  I'm going to reproduce this and fix.

I just managed to reproduce this using two sessions on master branch.

session 1
    session 2

# create table test with (autovacuum_enabled = false) as (select
array[1] ar from generate_series(1,20000) i);
# create index test_ar_idx on test using gin (ar);
# vacuum analyze test;
# delete from test;

    # set enable_seqscan = off;
    gdb> b ginbtree.c:150
    # select * from test where ar @> '{1}'::integer[];
    Step in gdb just before ReadBuffer() in ReleaseAndReadBuffer().

gdb> b ginvacuum.c:155
# vacuum test;

    gdb > continue
gdb> continue

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)
Next
From: Alvaro Herrera
Date:
Subject: Re: [DOC] Document concurrent index builds waiting on each other