Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: feichanghong <feichanghong(at)qq(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit
Date: 2024-01-22 16:01:03
Message-ID: d8f0b068-0e6e-4b2c-8932-62507eb7e1c6@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

(Adding Michael for the fault-injection parts)

On 22/01/2024 17:27, feichanghong wrote:
> Thank you for your attention.
>
>> Thanks, I'll look into this. The fix seems fine at a quick glance, but
>> I'll think about the performance aspect a bit more.

From a performance point of view, this doesn't matter. Incomplete split
are extremely rare. For convenience, though, I added a new function
specifically for handling these "leftover" incomplete splits as opposed
to finishing a split that you just made, which performs the
lock-upgrade. See attached. I think that helps with readability, and
makes it less likely that we'll forget the lock-upgrade in the future if
the insertion code is refactored.

> I apologize for the mistake in my patch: "if
> GinPageIsIncompleteSplit(page)" is
> missing a parenthesis, it should be "if (GinPageIsIncompleteSplit(page))"
>
>> Another way to create a scenario with incomplete splits, which doesn't
>> involve any crashes or errors, would be to perform PITR to just
>> between the insert and the finish-split records. But the
>> fault-injection seems easier.
> I agree it, fault-injection is easier than PITR.

The attached patch contains a test case using the fault-injection facility.

Michael, it was a pleasure to write this test with the injection points,
compared to trying to set up PITR at just the right moment. Thank you!
Since this is the first test that uses it, I didn't have any precedence
to copy-paste; can you take a look and verify if this is how you
imagined the facility to be used?

--
Heikki Linnakangas
Neon (https://neon.tech)

Attachment Content-Type Size
v2-0001-Fix-locking-when-fixing-an-incomplete-split-of-a-.patch text/x-patch 19.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message feichanghong 2024-01-22 16:21:58 Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit
Previous Message Tom Lane 2024-01-22 15:44:46 Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries