Skip to content

Commit ab80a2e

Browse files
committed
Fix bad on_shutdown call and make pyright happy
1 parent 13619f8 commit ab80a2e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

patroni/ha.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,8 +1626,7 @@ def on_shutdown(checkpoint_location: int, prev_location: int) -> None:
16261626
status['released'] = True
16271627

16281628
if mode == 'multisite':
1629-
on_shutdown = self.patroni.multisite.on_shutdown # pyright: ignore [reportAssignmentType] # noqa: F811
1630-
1629+
on_shutdown = self.patroni.multisite.on_shutdown
16311630
def before_shutdown() -> None:
16321631
if self.state_handler.mpp_handler.is_coordinator():
16331632
self.state_handler.mpp_handler.on_demote()
@@ -1643,7 +1642,7 @@ def before_shutdown() -> None:
16431642

16441643
# for demotion to a standby cluster we need shutdown checkpoint lsn to be written to optime, not the prev one
16451644
checkpoint_lsn, prev_lsn = self.state_handler.latest_checkpoint_locations() \
1646-
if mode == 'graceful' else (None, None)
1645+
if mode in ('graceful', 'multisite') else (None, None)
16471646

16481647
is_standby_leader = mode == 'demote-cluster' and not status['released']
16491648
if is_standby_leader:
@@ -1660,8 +1659,7 @@ def before_shutdown() -> None:
16601659
time.sleep(2) # Give a time to somebody to take the leader lock
16611660

16621661
if mode == 'multisite':
1663-
self.patroni.multisite.on_shutdown(
1664-
self.state_handler.latest_checkpoint_location(), None) # pyright: ignore [reportArgumentType]
1662+
self.patroni.multisite.on_shutdown(checkpoint_lsn, prev_lsn) # pyright: ignore [reportArgumentType] # noqa: F811
16651663

16661664
if mode == 'demote-cluster':
16671665
if demote_cluster_with_archive:

0 commit comments

Comments
 (0)