Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions patroni/multisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,17 @@ def _update_history(self, cluster: Cluster):
if isinstance(cluster.history.lines[0], dict):
history_state = cluster.history.lines[0]
if history_state.get('last_leader') != self.name: # pyright: ignore [reportUnknownMemberType]
new_state = (history_state.get('switches', 0) + 1, 0, '', self.name) # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
self.dcs.set_history_value(json.dumps(new_state)) # FIXME: append instead
state = [(history_state.get('switches', 0), 0, '', history_state.get('last_leader'))] # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
state.append((history_state.get('switches', 0) + 1, 0, '', self.name)) # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
self.dcs.set_history_value(json.dumps(state))
else:
history_state = cluster.history.lines[-1]
if len(history_state) > 3 and history_state[3] != self.name:
new_state = (history_state[0] + 1, 0, '', self.name)
self.dcs.set_history_value(json.dumps(cluster.history.lines.append(new_state)))
cluster.history.lines.append(new_state)
self.dcs.set_history_value(json.dumps(cluster.history.lines))
else: # no history yet, set initial item
self.dcs.set_history_value(json.dumps([(0, 0, '', self.name)])) # FIXME: append to list instead
self.dcs.set_history_value(json.dumps([(0, 0, '', self.name)]))

def _check_for_failover(self, cluster: Cluster):
if cluster.failover and cluster.failover.target_site:
Expand Down
Loading