Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit242e01f

Browse files
author
Sofia Kopikova
committed
Fix error 'Is another postmaster already running on port XXX'
Sometimes when we abnormally shutdown node its port stays busy. So Iadded retry attempts to start() function in case we encounter sucherror. Test for this case was added (test_the_same_port).
1 parent4c70b80 commit242e01f

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

‎testgres/node.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,14 +726,29 @@ def start(self, params=[], wait=True):
726726
"start"
727727
]+params# yapf: disable
728728

729-
try:
730-
exit_status,out,error=execute_utility(_params,self.utils_log_file,verbose=True)
731-
iferrorand'does not exist'inerror:
732-
raiseException
733-
exceptExceptionase:
734-
msg='Cannot start node'
735-
files=self._collect_special_files()
736-
raise_from(StartNodeException(msg,files),e)
729+
startup_retries=5
730+
whileTrue:
731+
try:
732+
exit_status,out,error=execute_utility(_params,self.utils_log_file,verbose=True)
733+
iferrorand'does not exist'inerror:
734+
raiseException
735+
exceptExceptionase:
736+
files=self._collect_special_files()
737+
ifany(len(file)>1and'Is another postmaster already '
738+
'running on port'infileforfileinfiles):
739+
print("Detected an issue with connecting to port {0}. "
740+
"Trying another port after a 5-second sleep...".format(self.port))
741+
self.port=reserve_port()
742+
options= {}
743+
options['port']=str(self.port)
744+
self.set_auto_conf(options)
745+
startup_retries-=1
746+
time.sleep(5)
747+
continue
748+
749+
msg='Cannot start node'
750+
raise_from(StartNodeException(msg,files),e)
751+
break
737752
self._maybe_start_logger()
738753
self.is_started=True
739754
returnself

‎tests/test_simple.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,14 @@ def test_parse_pg_version(self):
10331033
# Macos
10341034
assertparse_pg_version("postgres (PostgreSQL) 14.9 (Homebrew)")=="14.9"
10351035

1036+
deftest_the_same_port(self):
1037+
withget_new_node()asnode:
1038+
node.init().start()
1039+
1040+
withget_new_node()asnode2:
1041+
node2.port=node.port
1042+
node2.init().start()
1043+
10361044

10371045
if__name__=='__main__':
10381046
ifos.environ.get('ALT_CONFIG'):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp