diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py index 46bb753bb015..284c51e4630b 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py @@ -726,10 +726,6 @@ def get_current_token_for_writer(self, instance_name: str) -> int: instance_name, self._persisted_upto_position ) - max_pos = max( - self._current_positions.values(), default=self._persisted_upto_position - ) - # We want to return the maximum "current token" that we can for a # writer, this helps ensure that streams progress as fast as # possible. @@ -743,11 +739,11 @@ def get_current_token_for_writer(self, instance_name: str) -> int: # For our own instance when there's nothing in flight, it's safe # to advance to the maximum persisted position we've seen (as we # know that any new tokens we request will be greater). - max_pos = max( + max_pos_of_all_writers = max( self._current_positions.values(), default=self._persisted_upto_position, ) - pos = max(pos, max_pos) + pos = max(pos, max_pos_of_all_writers) return self._return_factor * pos