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

Commit06d1005

Browse files
committed
Add synchronous promotion support on pg of version < 10
1 parentc6e61b9 commit06d1005

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
@@ -662,17 +662,19 @@ def reload(self, params=[]):
662662
_params= [
663663
get_bin_path("pg_ctl"),
664664
"-D",self.data_dir,
665-
"-w",# wait
666665
"reload"
667666
]+params# yapf: disable
668667

669668
execute_utility(_params,self.utils_log_file)
670669

671670
returnself
672671

673-
defpromote(self):
672+
defpromote(self,dbname=None,username=None):
674673
"""
675-
Promote standby instance to master using pg_ctl.
674+
Promote standby instance to master using pg_ctl. For PostgreSQL versions
675+
below 10 some additional actions required to ensure that instance
676+
became writable and hence `dbname` and `username` parameters may be
677+
needed.
676678
677679
Returns:
678680
This instance of :class:`.PostgresNode`.
@@ -687,7 +689,19 @@ def promote(self):
687689

688690
execute_utility(_params,self.utils_log_file)
689691

690-
# Node becomes master itself
692+
# for versions below 10 `promote` is asynchronous so we need to wait
693+
# until it actually becomes writable
694+
ifnotpg_version_ge("10"):
695+
check_query="SHOW transaction_read_only"
696+
697+
self.poll_query_until(
698+
query=check_query,
699+
expected="on",
700+
dbname=dbname,
701+
username=username,
702+
max_attempts=0)# infinite
703+
704+
# node becomes master itself
691705
self._master=None
692706

693707
returnself

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp