This is an automated email from the ASF dual-hosted git repository. yjhjstz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 6039d4ed4ff8b199318e8ad286b7e157ca60b27c Author: Asim R P <[email protected]> AuthorDate: Tue May 18 21:58:06 2021 +0530 Confine Greenplum-specific WAL replication behavior to coordinator Although WAL replication is used as the HA mechanism by all segments in a Greenplum cluster, there are some differences in how it is used by coordinator/standby and by primary/mirror segments. One such difference is the use of replication slots. Primary/mirror WAL replication makes use of replication slots to ensure WAL that a primary retains WAL that may still be needed by its mirror. Replication slots are not used for coordinator/standby. To ensure that coordinator retains WAL that is not yet received by the standby, possibly due to replication lag, a special mechanism is used by coordinator to track the flush location of standby. This patch confinces the use of this special mechanism to coordinator, the mechanism is no longer used by primary segments. Ideally, coordinator/standby may also make use of replication slots. The GUC max_slot_wal_keep_size can be set to the lowest value of (checkpoint_segments * XLOG_BLCKSZ) on coordinator to ensure that WAL doesn't fill up disk space when the standby goes down. That could done in a followup patch. Reviewed by: Ashwin Agrawal <[email protected]> Reviewed by: Paul Guo <[email protected]> (cherry picked from commit 0f2d65f497245eb00b5fc544cf609e79ddd75226) --- src/backend/access/transam/xlog.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index df5ae6b3c3..79bfd61bf5 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1013,7 +1013,6 @@ static int get_sync_bit(int method); /* New functions added for WAL replication */ static void XLogProcessCheckpointRecord(XLogReaderState *rec); - static void CopyXLogRecordToWAL(int write_len, bool isLogSwitch, XLogRecData *rdata, XLogRecPtr StartPos, XLogRecPtr EndPos); @@ -10523,8 +10522,14 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr PriorRedoPtr) /* * Calculate how many segments are kept by slots first, adjusting for * max_slot_wal_keep_size. + * + * Greenplum: coordinator needs a different way to determine the keep + * point as replication slot is not created there. */ - keep = XLogGetReplicationSlotMinimumLSN(); + keep = IS_QUERY_DISPATCHER() ? + WalSndCtlGetXLogCleanUpTo() : + XLogGetReplicationSlotMinimumLSN(); + #ifdef FAULT_INJECTOR /* * Let the WAL still needed be removed. This is used to test if WAL sender --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
