Re: BUG #18213: Standby's repeatable read isolation level transaction encountered a "nonrepeatable read" problem

From: 费长红 <feichanghong(at)qq(dot)com>
To: zhihuifan1213 <zhihuifan1213(at)163(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18213: Standby's repeatable read isolation level transaction encountered a "nonrepeatable read" problem
Date: 2023-12-05 11:47:27
Message-ID: tencent_741FAA26281C9708004A6AEF2219D49D6F08@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Yes, the existing "ProcArrayGetReplicationSlotXmin" function has met the functional requirements and I have updated it in the attachment.

Best regards,

Changhong Fei

------------------&nbsp;Original&nbsp;------------------
From: "zhihuifan1213" <zhihuifan1213(at)163(dot)com&gt;;
Date:&nbsp;Wed, Nov 29, 2023 03:50 PM
To:&nbsp;"费长红"<feichanghong(at)qq(dot)com&gt;;
Cc:&nbsp;"pgsql-bugs"<pgsql-bugs(at)lists(dot)postgresql(dot)org&gt;;
Subject:&nbsp;Re: 回复: BUG #18213: Standby's repeatable read isolation level transaction encountered a "nonrepeatable read" problem

"费长红" <feichanghong(at)qq(dot)com&gt; writes:

&gt; -------------------------------------------------------------------------------------------------------------------------
&gt;
&gt;&nbsp; *&nbsp; 起个啥名好呢&nbsp;
&gt;&nbsp;&nbsp;&nbsp; feichanghong(at)qq(dot)com&nbsp;
&gt;&nbsp;
&gt; Indeed, I simply implemented and verified the solution. In the above test, the "create index" command on RW will hang
&gt; until the transaction on standby is committed or aborted.

I think this is acceptable since its behavior is same as we wait for the
transactions in primary.

&gt; In addition, even if there is no select query on the standby, RW's "create index" command may wait for a period of time,
&gt; which affected by the wal_receiver_status_interval parameter.

The "wait" happens at the very last of index building, so the building
stages gives an enough time for standby to exceeds the xmin, so in a
real case, I think the overhead will be pretty low.

&gt; You can see attachment for the patch.

I take a look at the that, function GetReplicationSlotXmin should be not
needed. You can use ProcArrayGetReplicationSlotXmin directly.

After searching the caller of WaitForOlderSnapshots, I think this bug
probably has impact on "deteach partition concurrently" / "reindex
concurrently" features.&nbsp; All of them needs the same fix.

--
Best Regards
Andy Fan

Attachment Content-Type Size
wait_replication_slot_xmin_v2.patch application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message king tomo 2023-12-05 11:50:00 Re: BUG #18224: message bug in libpqwalreceiver.c.
Previous Message Richard Guo 2023-12-05 02:35:03 Re: BUG #18187: Unexpected error: "variable not found in subplan target lists" triggered by JOIN