From efed2fccaad4c5c8e3ad99b6e7479cc944bca621 Mon Sep 17 00:00:00 2001 From: Xin Zhang Date: Tue, 19 Sep 2017 16:51:15 -0700 Subject: [PATCH] Add new primary and mirror in gp_segment_configuration as not-in-sync. Under SEGWALREP, the mode for gp_segment_configuration is 'n' for not-in-sync and 's' for in-sync. When new primary or mirror is added to the cluster, the initial state of the mode should be 'n' instead of 's' (in the original filerep mode.) If mirror exists and synchronized with the primary, then the mode will be updated to 's' to indicate the primary-mirror pair are in-sync. Signed-off-by: Ashwin Agrawal --- src/backend/utils/gp/segadmin.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/utils/gp/segadmin.c b/src/backend/utils/gp/segadmin.c index e330ec9fc0..df2e84c23f 100644 --- a/src/backend/utils/gp/segadmin.c +++ b/src/backend/utils/gp/segadmin.c @@ -782,7 +782,11 @@ gp_add_segment_primary(PG_FUNCTION_ARGS) new.db.dbid = get_availableDbId(); new.db.role = SEGMENT_ROLE_PRIMARY; new.db.preferred_role = SEGMENT_ROLE_PRIMARY; +#ifdef USE_SEGWALREP + new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_NOTINSYNC; +#else new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_INSYNC; +#endif new.db.status = GP_SEGMENT_CONFIGURATION_STATUS_UP; new.db.filerep_port = -1; @@ -853,6 +857,11 @@ gp_add_segment(PG_FUNCTION_ARGS) mirroring_sanity_check(MASTER_ONLY | SUPERUSER, "gp_add_segment"); +#ifdef USE_SEGWALREP + new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_NOTINSYNC; + elog(NOTICE, "mode is changed to GP_SEGMENT_CONFIGURATION_MODE_NOTINSYNC under walrep."); +#endif + add_segment(new, fsmap); PG_RETURN_INT16(new.db.dbid); @@ -941,7 +950,11 @@ gp_add_segment_mirror(PG_FUNCTION_ARGS) mirroring_sanity_check(MASTER_ONLY | SUPERUSER, "gp_add_segment_mirror"); new.db.dbid = get_availableDbId(); +#ifdef USE_SEGWALREP + new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_NOTINSYNC; +#else new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_INSYNC; +#endif new.db.status = GP_SEGMENT_CONFIGURATION_STATUS_UP; new.db.role = SEGMENT_ROLE_MIRROR; new.db.preferred_role = SEGMENT_ROLE_MIRROR; -- GitLab