mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Flush logical slots to disk during a shutdown checkpoint if required.
It's entirely possible for a logical slot to have a confirmed_flush LSN higher than the last value saved on disk while not being marked as dirty. Currently, it is not a major problem but a later patch adding support for the upgrade of slots relies on that value being properly flushed to disk. It can also help avoid processing the same transactions again in some boundary cases after the clean shutdown and restart. Say, we process some transactions for which we didn't send anything downstream (the changes got filtered) but the confirm_flush LSN is updated due to keepalives. As we don't flush the latest value of confirm_flush LSN, it may lead to processing the same changes again without this patch. The approach taken by this patch has been suggested by Ashutosh Bapat. Author: Vignesh C, Julien Rouhaud, Kuroda Hayato Reviewed-by: Amit Kapila, Dilip Kumar, Michael Paquier, Ashutosh Bapat, Peter Smith, Hou Zhijie Discussion: http://postgr.es/m/CAA4eK1JzJagMmb_E8D4au=GYQkxox0AfNBm1FbP7sy7t4YWXPQ@mail.gmail.com Discussion: http://postgr.es/m/TYAPR01MB58664C81887B3AF2EB6B16E3F5939@TYAPR01MB5866.jpnprd01.prod.outlook.com
This commit is contained in:
@@ -178,6 +178,13 @@ typedef struct ReplicationSlot
|
||||
XLogRecPtr candidate_xmin_lsn;
|
||||
XLogRecPtr candidate_restart_valid;
|
||||
XLogRecPtr candidate_restart_lsn;
|
||||
|
||||
/*
|
||||
* This value tracks the last confirmed_flush LSN flushed which is used
|
||||
* during a shutdown checkpoint to decide if logical's slot data should be
|
||||
* forcibly flushed or not.
|
||||
*/
|
||||
XLogRecPtr last_saved_confirmed_flush;
|
||||
} ReplicationSlot;
|
||||
|
||||
#define SlotIsPhysical(slot) ((slot)->data.database == InvalidOid)
|
||||
@@ -241,7 +248,7 @@ extern void ReplicationSlotNameForTablesync(Oid suboid, Oid relid, char *syncslo
|
||||
extern void ReplicationSlotDropAtPubNode(WalReceiverConn *wrconn, char *slotname, bool missing_ok);
|
||||
|
||||
extern void StartupReplicationSlots(void);
|
||||
extern void CheckPointReplicationSlots(void);
|
||||
extern void CheckPointReplicationSlots(bool is_shutdown);
|
||||
|
||||
extern void CheckSlotRequirements(void);
|
||||
extern void CheckSlotPermissions(void);
|
||||
|
||||
Reference in New Issue
Block a user