Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
ID GEN STUFF
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jan 17, 2023
1 parent 0249787 commit 4616977
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,20 +699,23 @@ def _add_persisted_position(self, new_id: int) -> None:
# current position to the latest position seen. This allows the instance
# to report a recent position when asked, rather than a potentially old
# one (if this instance hasn't written anything for a while).
our_current_position = self._current_positions.get(self._instance_name)
if (
our_current_position
and not self._unfinished_ids
and not self._in_flight_fetches
):
self._current_positions[self._instance_name] = max(
our_current_position, new_id
)

# We move the current min position up if the minimum current positions
# of all instances is higher (since by definition all positions less
# that that have been persisted).
min_curr = min(self._current_positions.values(), default=0)
min_curr = min(
(
token
for name, token in self._current_positions.items()
if name != self._instance_name
),
default=0,
)

our_current_position = self._current_positions.get(self._instance_name)
if our_current_position and (self._unfinished_ids or self._in_flight_fetches):
min_curr = min(min_curr, our_current_position)

self._persisted_upto_position = max(min_curr, self._persisted_upto_position)

# We now iterate through the seen positions, discarding those that are
Expand Down

0 comments on commit 4616977

Please sign in to comment.