postgresql/src/include/nodes/replnodes.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
2.1 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* replnodes.h
* definitions for replication grammar parse nodes
*
*
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/nodes/replnodes.h
*
*-------------------------------------------------------------------------
*/
#ifndef REPLNODES_H
#define REPLNODES_H
#include "access/xlogdefs.h"
#include "nodes/pg_list.h"
typedef enum ReplicationKind
{
REPLICATION_KIND_PHYSICAL,
REPLICATION_KIND_LOGICAL
} ReplicationKind;
/* ----------------------
* IDENTIFY_SYSTEM command
* ----------------------
*/
typedef struct IdentifySystemCmd
{
NodeTag type;
} IdentifySystemCmd;
/* ----------------------
* BASE_BACKUP command
* ----------------------
*/
typedef struct BaseBackupCmd
{
NodeTag type;
List *options;
} BaseBackupCmd;
/* ----------------------
* CREATE_REPLICATION_SLOT command
* ----------------------
*/
typedef struct CreateReplicationSlotCmd
{
NodeTag type;
char *slotname;
ReplicationKind kind;
char *plugin;
bool temporary;
List *options;
} CreateReplicationSlotCmd;
/* ----------------------
* DROP_REPLICATION_SLOT command
* ----------------------
*/
typedef struct DropReplicationSlotCmd
{
NodeTag type;
char *slotname;
bool wait;
} DropReplicationSlotCmd;
/* ----------------------
* START_REPLICATION command
* ----------------------
*/
typedef struct StartReplicationCmd
{
NodeTag type;
ReplicationKind kind;
char *slotname;
Allow a streaming replication standby to follow a timeline switch. Before this patch, streaming replication would refuse to start replicating if the timeline in the primary doesn't exactly match the standby. The situation where it doesn't match is when you have a master, and two standbys, and you promote one of the standbys to become new master. Promoting bumps up the timeline ID, and after that bump, the other standby would refuse to continue. There's significantly more timeline related logic in streaming replication now. First of all, when a standby connects to primary, it will ask the primary for any timeline history files that are missing from the standby. The missing files are sent using a new replication command TIMELINE_HISTORY, and stored in standby's pg_xlog directory. Using the timeline history files, the standby can follow the latest timeline present in the primary (recovery_target_timeline='latest'), just as it can follow new timelines appearing in an archive directory. START_REPLICATION now takes a TIMELINE parameter, to specify exactly which timeline to stream WAL from. This allows the standby to request the primary to send over WAL that precedes the promotion. The replication protocol is changed slightly (in a backwards-compatible way although there's little hope of streaming replication working across major versions anyway), to allow replication to stop when the end of timeline reached, putting the walsender back into accepting a replication command. Many thanks to Amit Kapila for testing and reviewing various versions of this patch.
2012-12-13 18:00:00 +01:00
TimeLineID timeline;
XLogRecPtr startpoint;
List *options;
} StartReplicationCmd;
Allow a streaming replication standby to follow a timeline switch. Before this patch, streaming replication would refuse to start replicating if the timeline in the primary doesn't exactly match the standby. The situation where it doesn't match is when you have a master, and two standbys, and you promote one of the standbys to become new master. Promoting bumps up the timeline ID, and after that bump, the other standby would refuse to continue. There's significantly more timeline related logic in streaming replication now. First of all, when a standby connects to primary, it will ask the primary for any timeline history files that are missing from the standby. The missing files are sent using a new replication command TIMELINE_HISTORY, and stored in standby's pg_xlog directory. Using the timeline history files, the standby can follow the latest timeline present in the primary (recovery_target_timeline='latest'), just as it can follow new timelines appearing in an archive directory. START_REPLICATION now takes a TIMELINE parameter, to specify exactly which timeline to stream WAL from. This allows the standby to request the primary to send over WAL that precedes the promotion. The replication protocol is changed slightly (in a backwards-compatible way although there's little hope of streaming replication working across major versions anyway), to allow replication to stop when the end of timeline reached, putting the walsender back into accepting a replication command. Many thanks to Amit Kapila for testing and reviewing various versions of this patch.
2012-12-13 18:00:00 +01:00
/* ----------------------
* READ_REPLICATION_SLOT command
* ----------------------
*/
typedef struct ReadReplicationSlotCmd
{
NodeTag type;
char *slotname;
} ReadReplicationSlotCmd;
Allow a streaming replication standby to follow a timeline switch. Before this patch, streaming replication would refuse to start replicating if the timeline in the primary doesn't exactly match the standby. The situation where it doesn't match is when you have a master, and two standbys, and you promote one of the standbys to become new master. Promoting bumps up the timeline ID, and after that bump, the other standby would refuse to continue. There's significantly more timeline related logic in streaming replication now. First of all, when a standby connects to primary, it will ask the primary for any timeline history files that are missing from the standby. The missing files are sent using a new replication command TIMELINE_HISTORY, and stored in standby's pg_xlog directory. Using the timeline history files, the standby can follow the latest timeline present in the primary (recovery_target_timeline='latest'), just as it can follow new timelines appearing in an archive directory. START_REPLICATION now takes a TIMELINE parameter, to specify exactly which timeline to stream WAL from. This allows the standby to request the primary to send over WAL that precedes the promotion. The replication protocol is changed slightly (in a backwards-compatible way although there's little hope of streaming replication working across major versions anyway), to allow replication to stop when the end of timeline reached, putting the walsender back into accepting a replication command. Many thanks to Amit Kapila for testing and reviewing various versions of this patch.
2012-12-13 18:00:00 +01:00
/* ----------------------
* TIMELINE_HISTORY command
* ----------------------
*/
typedef struct TimeLineHistoryCmd
{
NodeTag type;
TimeLineID timeline;
} TimeLineHistoryCmd;
#endif /* REPLNODES_H */