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 @@ -662,17 +662,19 @@ def reload(self, params=[]):
662
662
_params = [
663
663
get_bin_path ("pg_ctl" ),
664
664
"-D" , self .data_dir ,
665
- "-w" , # wait
666
665
"reload"
667
666
] + params # yapf: disable
668
667
669
668
execute_utility (_params , self .utils_log_file )
670
669
671
670
return self
672
671
673
- def promote (self ):
672
+ def promote (self , dbname = None , username = None ):
674
673
"""
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.
676
678
677
679
Returns:
678
680
This instance of :class:`.PostgresNode`.
@@ -687,7 +689,19 @@ def promote(self):
687
689
688
690
execute_utility (_params , self .utils_log_file )
689
691
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
+ if not pg_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
691
705
self ._master = None
692
706
693
707
return self
You can’t perform that action at this time.
0 commit comments