Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0f51fd

Browse files
author
Amit Kapila
committed
Don't retreat slot's confirmed_flush LSN.
Prevent moving the confirmed_flush backwards, as this could lead to dataduplication issues caused by replicating already replicated changes.This can happen when a client acknowledges an LSN it doesn't have to doanything for, and thus didn't store persistently. After a restart, theclient can send the prior LSN that it stored persistently as anacknowledgement, but we need to ignore such an LSN to avoid retreatingconfirm_flush LSN.Diagnosed-by: Zhijie Hou <houzj.fnst@fujitsu.com>Author: shveta malik <shveta.malik@gmail.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>Tested-by: Nisha Moond <nisha.moond412@gmail.com>Backpatch-through: 13Discussion:https://postgr.es/m/CAJpy0uDZ29P=BYB1JDWMCh-6wXaNqMwG1u1mB4=10Ly0x7HhwQ@mail.gmail.comDiscussion:https://postgr.es/m/OS0PR01MB57164AB5716AF2E477D53F6F9489A@OS0PR01MB5716.jpnprd01.prod.outlook.com
1 parent253cf66 commitc0f51fd

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

‎src/backend/replication/logical/logical.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,19 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
18301830

18311831
SpinLockAcquire(&MyReplicationSlot->mutex);
18321832

1833-
MyReplicationSlot->data.confirmed_flush=lsn;
1833+
/*
1834+
* Prevent moving the confirmed_flush backwards, as this could lead to
1835+
* data duplication issues caused by replicating already replicated
1836+
* changes.
1837+
*
1838+
* This can happen when a client acknowledges an LSN it doesn't have
1839+
* to do anything for, and thus didn't store persistently. After a
1840+
* restart, the client can send the prior LSN that it stored
1841+
* persistently as an acknowledgement, but we need to ignore such an
1842+
* LSN. See similar case handling in CreateDecodingContext.
1843+
*/
1844+
if (lsn>MyReplicationSlot->data.confirmed_flush)
1845+
MyReplicationSlot->data.confirmed_flush=lsn;
18341846

18351847
/* if we're past the location required for bumping xmin, do so */
18361848
if (MyReplicationSlot->candidate_xmin_lsn!=InvalidXLogRecPtr&&
@@ -1895,7 +1907,14 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
18951907
else
18961908
{
18971909
SpinLockAcquire(&MyReplicationSlot->mutex);
1898-
MyReplicationSlot->data.confirmed_flush=lsn;
1910+
1911+
/*
1912+
* Prevent moving the confirmed_flush backwards. See comments above
1913+
* for the details.
1914+
*/
1915+
if (lsn>MyReplicationSlot->data.confirmed_flush)
1916+
MyReplicationSlot->data.confirmed_flush=lsn;
1917+
18991918
SpinLockRelease(&MyReplicationSlot->mutex);
19001919
}
19011920
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp