Re: Deadlock between concurrent index builds on different tables

From: Jeremy Finzel <finzelj(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Deadlock between concurrent index builds on different tables
Date: 2017-12-27 03:03:18
Message-ID: CAMa1XUiwCVAdcji4uwXjiH=Wha3b85gSszgJBt7G1KHdim1sCg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 26, 2017 at 11:11 AM, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> Jeremy Finzel wrote:
> > On Tue, Dec 26, 2017 at 10:28 AM, Alvaro Herrera <
> alvherre(at)alvh(dot)no-ip(dot)org>
> > wrote:
> >
> > > Jeremy Finzel wrote:
> > > > >
> > > > >> Each index build needs to wait for all other transactions
> > > > >> (Including the ones used by the other index build) to finish.
> > > > >> So I don't think a deadlock here is unexpected.
> > >
> > > > Does that mean I should never build more than one concurrent index at
> > > > a time within the entire cluster? If so, that is not clear from the
> > > > documentation.
> > >
> > > No, there is no such expectation. Jeff analyzed your scenario,
> > > discovered a bug and sent a patch to fix it -- care to test it and
> > > report back? You can get it from here:
> > >
> > > https://www.postgresql.org/message-id/CAMkU=
> 1ztk3TpQdcUNbxq93pc80FrXUjpDWL
> > > GMeVBDx71GHNwZQ(at)mail(dot)gmail(dot)com
>
> > I would be thrilled to review it, but I need a little direction as I have
> > not done a patch review before. I have been reading through some of the
> > developer FAQ and patch info. The attached file is simply a git diff, so
> > I'm not sure how I am to use this? Is there a specific source version I
> > can download and compile? I know where to get the current master, etc.,
> > from git, but where can I get the patched version or what is the proper
> way
> > to apply the patch to current master?
>
> I don't think a patch review as such is necessary -- that code is very
> complex and you'd need to learn about a lot of internals (though I won't
> stop if you want to learn). I was thinking about testing it, instead.
>
> To create a patched build,
> 1. get a clone with the branch you're on. Assuming you're on 9.6, it'd
> be like this
> git clone <URL> -b REL9_6_STABLE
>
> 2. apply the patch on top
> cd postgresql
> patch -p1 < /path/to/file.diff
> # you could use "git apply" instead (or "git am", but not with this one)
>
> 3. configure and make
> ./configure <configure options>
> make
> make install
>
> 4. run it
> initdb -D <somedir> # to create a fresh datadir
> pg_ctl <whatever>
>
> You may need additional packages (zlib devel, readline devel, others;
> see https://www.postgresql.org/docs/9.6/static/installation.html)
>
> For the options in step 3 you could use whatever your current server
> has; use "pg_config --configure" to find these out. You're gonna need
> same flags if you want to use your existing data directory.
>
> --
> Álvaro Herrera https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

Many thanks for the great and simple explanation.

I was able to get this compiled, and ran the test before on stock 9.6.6,
then on this patched version. I indeed reproduced it on 9.6.6, but on the
patched version, it indeed fixes my issue!

I am indeed very interested in learning more about the whole patch review
process, but I will have to save that for another day!

Let me know if you need me to check anything else!

Thanks,
Jeremy

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michelle Konzack 2017-12-27 07:53:11 Re: [table partitioning] How many partitions are possibel?
Previous Message Stuart McGraw 2017-12-27 02:21:22 postgresql-10 for ubuntu-17.10 (artful)?