提交 1bb52ea8 编写于 作者: H Huiliang.liu 提交者: Huiliang Liu

Add max_retries flag for gpload (#9606)

Add max_retries flag for gpload. It indicates the max times on connecting to GPDB timed out.
max_retries default value is 0 which means no retry.
If max_retries is -1 or other negative value, it means retry forever.

Test has been done manually.

( cherry pick from master commit: b891b85b)
上级 655eaa04
...@@ -18,6 +18,7 @@ Options: ...@@ -18,6 +18,7 @@ Options:
-l logfile: log output to logfile -l logfile: log output to logfile
--no_auto_trans: do not wrap gpload in transaction --no_auto_trans: do not wrap gpload in transaction
--gpfdist_timeout timeout: gpfdist timeout value --gpfdist_timeout timeout: gpfdist timeout value
--max_retries retry_times: max retry times on gpdb connection timed out. 0 means disabled, -1 means forever
--version: print version number and exit --version: print version number and exit
-?: help -?: help
''' '''
...@@ -1157,6 +1158,7 @@ class gpload: ...@@ -1157,6 +1158,7 @@ class gpload:
self.startTimestamp = time.time() self.startTimestamp = time.time()
self.error_table = False self.error_table = False
self.gpdb_version = "" self.gpdb_version = ""
self.options.max_retries = 0
seenv = False seenv = False
seenq = False seenq = False
...@@ -1217,6 +1219,9 @@ class gpload: ...@@ -1217,6 +1219,9 @@ class gpload:
elif argv[0]=='-f': elif argv[0]=='-f':
configFilename = argv[1] configFilename = argv[1]
argv = argv[2:] argv = argv[2:]
elif argv[0]=='--max_retries':
self.options.max_retries = int(argv[1])
argv = argv[2:]
elif argv[0]=='--no_auto_trans': elif argv[0]=='--no_auto_trans':
self.options.no_auto_trans = True self.options.no_auto_trans = True
argv = argv[1:] argv = argv[1:]
...@@ -1841,6 +1846,18 @@ class gpload: ...@@ -1841,6 +1846,18 @@ class gpload:
if recurse > 10: if recurse > 10:
self.log(self.ERROR, "too many login attempt failures") self.log(self.ERROR, "too many login attempt failures")
self.setup_connection(recurse) self.setup_connection(recurse)
elif errorMessage.find("Connection timed out") != -1 and self.options.max_retries != 0:
recurse += 1
if self.options.max_retries > 0:
if recurse > self.options.max_retries: # retry failed
self.log(self.ERROR, "could not connect to database after retry %d times, " \
"error message:\n %s" % (recurse-1, errorMessage))
else:
self.log(self.INFO, "retry to connect to database, %d of %d times" % (recurse,
self.options.max_retries))
else: # max_retries < 0, retry forever
self.log(self.INFO, "retry to connect to database.")
self.setup_connection(recurse)
else: else:
self.log(self.ERROR, "could not connect to database: %s. Is " \ self.log(self.ERROR, "could not connect to database: %s. Is " \
"the Greenplum Database running on port %i?" % (errorMessage, "the Greenplum Database running on port %i?" % (errorMessage,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册