0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 12:23:48 +01:00

Reduce volume of 'Waiting for current token' logs, which were introduced in v1.109.0. (#17428)

Introduced in: #17215

This caused us a minor bit of grief as the volume of logs produced was
much higher than normal

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
This commit is contained in:
reivilibre 2024-07-23 11:51:34 +01:00 committed by GitHub
parent a9ee832e48
commit 1daae43f3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 5 deletions

1
changelog.d/17428.bugfix Normal file
View file

@ -0,0 +1 @@
Reduce volume of 'Waiting for current token' logs, which were introduced in v1.109.0.

View file

@ -773,6 +773,7 @@ class Notifier:
stream_token = await self.event_sources.bound_future_token(stream_token) stream_token = await self.event_sources.bound_future_token(stream_token)
start = self.clock.time_msec() start = self.clock.time_msec()
logged = False
while True: while True:
current_token = self.event_sources.get_current_token() current_token = self.event_sources.get_current_token()
if stream_token.is_before_or_eq(current_token): if stream_token.is_before_or_eq(current_token):
@ -783,11 +784,13 @@ class Notifier:
if now - start > 10_000: if now - start > 10_000:
return False return False
logger.info( if not logged:
"Waiting for current token to reach %s; currently at %s", logger.info(
stream_token, "Waiting for current token to reach %s; currently at %s",
current_token, stream_token,
) current_token,
)
logged = True
# TODO: be better # TODO: be better
await self.clock.sleep(0.5) await self.clock.sleep(0.5)

View file

@ -777,6 +777,13 @@ class RoomStreamToken(AbstractMultiWriterStreamToken):
return super().bound_stream_token(max_stream) return super().bound_stream_token(max_stream)
def __str__(self) -> str:
instances = ", ".join(f"{k}: {v}" for k, v in sorted(self.instance_map.items()))
return (
f"RoomStreamToken(stream: {self.stream}, topological: {self.topological}, "
f"instances: {{{instances}}})"
)
@attr.s(frozen=True, slots=True, order=False) @attr.s(frozen=True, slots=True, order=False)
class MultiWriterStreamToken(AbstractMultiWriterStreamToken): class MultiWriterStreamToken(AbstractMultiWriterStreamToken):
@ -873,6 +880,13 @@ class MultiWriterStreamToken(AbstractMultiWriterStreamToken):
return True return True
def __str__(self) -> str:
instances = ", ".join(f"{k}: {v}" for k, v in sorted(self.instance_map.items()))
return (
f"MultiWriterStreamToken(stream: {self.stream}, "
f"instances: {{{instances}}})"
)
class StreamKeyType(Enum): class StreamKeyType(Enum):
"""Known stream types. """Known stream types.
@ -1131,6 +1145,15 @@ class StreamToken:
return True return True
def __str__(self) -> str:
return (
f"StreamToken(room: {self.room_key}, presence: {self.presence_key}, "
f"typing: {self.typing_key}, receipt: {self.receipt_key}, "
f"account_data: {self.account_data_key}, push_rules: {self.push_rules_key}, "
f"to_device: {self.to_device_key}, device_list: {self.device_list_key}, "
f"groups: {self.groups_key}, un_partial_stated_rooms: {self.un_partial_stated_rooms_key})"
)
StreamToken.START = StreamToken( StreamToken.START = StreamToken(
RoomStreamToken(stream=0), 0, 0, MultiWriterStreamToken(stream=0), 0, 0, 0, 0, 0, 0 RoomStreamToken(stream=0), 0, 0, MultiWriterStreamToken(stream=0), 0, 0, 0, 0, 0, 0