Re: BUG #17949: Adding an index introduces serialisation anomalies.

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: artem(dot)anisimov(dot)255(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: BUG #17949: Adding an index introduces serialisation anomalies.
Date: 2023-06-20 22:54:15
Message-ID: CA+hUKGJQ5ijziJtnrZfo8-8dmfiCU8nJBTnpkVweBp2krN_6Ng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jun 20, 2023 at 1:22 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Tue, Jun 20, 2023 at 12:18 AM Dmitry Dolgov <9erthalion6(at)gmail(dot)com> wrote:
> > One thing I've noticed is that one can observe a similar issue using a
> > gin index and int[] for the "path" column, even applying changes from
> > the thread. The gin implementation does something similar to btree in
> > startScanEntry -- it lands in "No entry found" branch, but instead of
> > locking the relation it locks "the leaf page, to lock the place where
> > the entry would've been, had there been one". The similar fix retrying
> > ginFindLeafPage didn't solve the problem, even if locking the whole
> > relation instead, but maybe I'm missing something.
>
> Ouch. I would have to go and study gin's interlocking model, but one
> superficial bug I spotted is that ginget.c's collectMatchBitmap()
> calls PredicateLockPage(stack->buffer), where a block number is
> expected. I wish we had strong typedefs, to reject stuff like that at
> compile time. But fixing that alone isn't enough.
>
> In case someone who knows more about gin is interested in helping, I
> attach Artem's repro, modified to use gin.

This is probably going to go faster if I CC the authors of commit
0bef1c06. Any ideas about how we're missing rw-conflicts under high
concurrency?

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2023-06-20 23:01:39 Re: BUG #17975: Nested Loop Index Scan returning wrong result
Previous Message Joe Conway 2023-06-20 22:02:48 Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG