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

Commit7c48fae

Browse files
committed
Add synchronous promotion support on pg of version < 10
1 parent5ea4bd8 commit7c48fae

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

‎testgres/node.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,19 @@ def reload(self, params=[]):
683683
_params= [
684684
get_bin_path("pg_ctl"),
685685
"-D",self.data_dir,
686-
"-w",# wait
687686
"reload"
688687
]+params# yapf: disable
689688

690689
execute_utility(_params,self.utils_log_file)
691690

692691
returnself
693692

694-
defpromote(self):
693+
defpromote(self,dbname=None,username=None):
695694
"""
696-
Promote standby instance to master using pg_ctl.
695+
Promote standby instance to master using pg_ctl. For PostgreSQL versions
696+
below 10 some additional actions required to ensure that instance
697+
became writable and hence `dbname` and `username` parameters may be
698+
needed.
697699
698700
Returns:
699701
This instance of :class:`.PostgresNode`.
@@ -708,7 +710,19 @@ def promote(self):
708710

709711
execute_utility(_params,self.utils_log_file)
710712

711-
# Node becomes master itself
713+
# for versions below 10 `promote` is asynchronous so we need to wait
714+
# until it actually becomes writable
715+
ifnotpg_version_ge("10"):
716+
check_query="SHOW transaction_read_only"
717+
718+
self.poll_query_until(
719+
query=check_query,
720+
expected="on",
721+
dbname=dbname,
722+
username=username,
723+
max_attempts=0)# infinite
724+
725+
# node becomes master itself
712726
self._master=None
713727

714728
returnself

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp