You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2024/12/24 02:38:00 UTC
(cloudberry) 03/38: Use pg_ctl -t secs option for promote in gpactivatestandby
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit bc3025bafbb23de97fc446a4d8cbadd2c006b466
Author: Ashwin Agrawal <aa...@vmware.com>
AuthorDate: Tue Jul 5 18:10:39 2022 -0700
Use pg_ctl -t secs option for promote in gpactivatestandby
Since commit e7010c "pg_ctl: Add wait option to promote action" have
option -t to wait for required number of secs for promotion. Hence,
deleting the retry loop with dbconn.execSQL() logic to check for
promotion completion via connection acceptance.
Using -t option with 10 mins as timeout to align the value with
MIRROR_PROMOTION_TIMEOUT used in other part of codebase. Having
consistent timeout value for same operation is helpful.
Reviewed-by: Nikhil Kak <nk...@vmware.com>
Reviewed-by: Soumyadeep Chakraborty <so...@gmail.com>
---
gpMgmt/bin/gpactivatestandby | 28 ++++------------------------
1 file changed, 4 insertions(+), 24 deletions(-)
diff --git a/gpMgmt/bin/gpactivatestandby b/gpMgmt/bin/gpactivatestandby
index 813d6cd3f7..831355d196 100755
--- a/gpMgmt/bin/gpactivatestandby
+++ b/gpMgmt/bin/gpactivatestandby
@@ -316,29 +316,12 @@ def promote_standby(coordinator_data_dir):
"""Promote standby"""
logger.info('Promoting standby...')
+ # Keeping the timeout here consistent with
+ # MIRROR_PROMOTION_TIMEOUT which is defined as 10 mins
cmd = gp.Command('pg_ctl promote',
- 'pg_ctl promote -D %s' % coordinator_data_dir)
+ 'pg_ctl promote -D %s -t 600' % coordinator_data_dir)
cmd.run(validateAfter=True)
- logger.debug('Waiting for connection...')
- for i in range(50):
- try:
- dburl = dbconn.DbURL()
- conn = dbconn.connect(dburl, utility=True, logConn=False)
- # When the new coordinator is available for connections, we should
- # run a CHECKPOINT to force the new TimeLineID to be written to
- # the pg_control file.
- dbconn.execSQL(conn, 'CHECKPOINT')
- logger.info('Standby coordinator is promoted')
- conn.close()
- return True
- except pygresql.InternalError as e:
- pass
- time.sleep(1)
-
- return False
-
-
#-------------------------------------------------------------------------
# Main
#-------------------------------------------------------------------------
@@ -369,10 +352,7 @@ try:
# promote standby, only if the standby is running in recovery
if not requires_restart:
- res = promote_standby(options_.coordinator_data_dir)
- if not res:
- raise GpActivateStandbyException('Either the set port is incorrect or '
- 'the postmaster could not come up.')
+ promote_standby(options_.coordinator_data_dir)
# now we can access the catalog. promote action has already updated
# catalog, so array.coordinator is the old (promoted) standby at this point.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org