diff options
| author | Amit Kapila | 2024-04-03 08:34:59 +0000 |
|---|---|---|
| committer | Amit Kapila | 2024-04-03 08:34:59 +0000 |
| commit | 2ec005b4e29740f0d36e6646d149af192328b2ff (patch) | |
| tree | 666945f7acefb7bf88adb1a84ef22ce368581ae6 /src/include | |
| parent | e37662f22158c29bc55eda4eda1757f444cf701a (diff) | |
Ensure that the sync slots reach a consistent state after promotion without losing data.
We were directly copying the LSN locations while syncing the slots on the
standby. Now, it is possible that at some particular restart_lsn there are
some running xacts, which means if we start reading the WAL from that
location after promotion, we won't reach a consistent snapshot state at
that point. However, on the primary, we would have already been in a
consistent snapshot state at that restart_lsn so we would have just
serialized the existing snapshot.
To avoid this problem we will use the advance_slot functionality unless
the snapshot already exists at the synced restart_lsn location. This will
help us to ensure that snapbuilder/slot statuses are updated properly
without generating any changes. Note that the synced slot will remain as
RS_TEMPORARY till the decoding from corresponding restart_lsn can reach a
consistent snapshot state after which they will be marked as
RS_PERSISTENT.
Per buildfarm
Author: Hou Zhijie
Reviewed-by: Bertrand Drouvot, Shveta Malik, Bharath Rupireddy, Amit Kapila
Discussion: https://postgr.es/m/OS0PR01MB5716B3942AE49F3F725ACA92943B2@OS0PR01MB5716.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/replication/logical.h | 2 | ||||
| -rw-r--r-- | src/include/replication/snapbuild.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h index dc2df4ce92a..aff38e8d049 100644 --- a/src/include/replication/logical.h +++ b/src/include/replication/logical.h @@ -149,5 +149,7 @@ extern void ResetLogicalStreamingState(void); extern void UpdateDecodingStats(LogicalDecodingContext *ctx); extern bool LogicalReplicationSlotHasPendingWal(XLogRecPtr end_of_wal); +extern XLogRecPtr LogicalSlotAdvanceAndCheckSnapState(XLogRecPtr moveto, + bool *found_consistent_snapshot); #endif diff --git a/src/include/replication/snapbuild.h b/src/include/replication/snapbuild.h index fbdf3623969..a3360a1c5ea 100644 --- a/src/include/replication/snapbuild.h +++ b/src/include/replication/snapbuild.h @@ -91,4 +91,6 @@ extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running); extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn); +extern bool SnapBuildSnapshotExists(XLogRecPtr lsn); + #endif /* SNAPBUILD_H */ |
