File tree 1 file changed +18
-4
lines changed
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -683,17 +683,19 @@ def reload(self, params=[]):
683
683
_params = [
684
684
get_bin_path ("pg_ctl" ),
685
685
"-D" , self .data_dir ,
686
- "-w" , # wait
687
686
"reload"
688
687
] + params # yapf: disable
689
688
690
689
execute_utility (_params , self .utils_log_file )
691
690
692
691
return self
693
692
694
- def promote (self ):
693
+ def promote (self , dbname = None , username = None ):
695
694
"""
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.
697
699
698
700
Returns:
699
701
This instance of :class:`.PostgresNode`.
@@ -708,7 +710,19 @@ def promote(self):
708
710
709
711
execute_utility (_params , self .utils_log_file )
710
712
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
+ if not pg_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
712
726
self ._master = None
713
727
714
728
return self
You can’t perform that action at this time.
0 commit comments