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

Commit 0ec12a3

Browse files
authored
Reduce max time we wait for stream positions (#14881)
Now that we wait for stream positions whenever we do a HTTP replication hit, we need to be less brutal in the case where we do timeout (as we have bugs around this).
1 parent 65d0386 commit 0ec12a3

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

changelog.d/14881.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce max time we wait for stream positions.

synapse/replication/http/_base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ async def send_request(*, instance_name: str = "master", **kwargs: Any) -> Any:
352352
instance_name=instance_name,
353353
stream_name=stream_name,
354354
position=position,
355-
raise_on_timeout=False,
356355
)
357356

358357
return result
@@ -414,7 +413,6 @@ async def _check_auth_and_handle(
414413
instance_name=content[_STREAM_POSITION_KEY]["instance_name"],
415414
stream_name=stream_name,
416415
position=position,
417-
raise_on_timeout=False,
418416
)
419417

420418
if self.CACHE:

synapse/replication/tcp/client.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
logger = logging.getLogger(__name__)
6060

6161
# How long we allow callers to wait for replication updates before timing out.
62-
_WAIT_FOR_REPLICATION_TIMEOUT_SECONDS = 30
62+
_WAIT_FOR_REPLICATION_TIMEOUT_SECONDS = 5
6363

6464

6565
class DirectTcpReplicationClientFactory(ReconnectingClientFactory):
@@ -326,7 +326,6 @@ async def wait_for_stream_position(
326326
instance_name: str,
327327
stream_name: str,
328328
position: int,
329-
raise_on_timeout: bool = True,
330329
) -> None:
331330
"""Wait until this instance has received updates up to and including
332331
the given stream position.
@@ -335,8 +334,6 @@ async def wait_for_stream_position(
335334
instance_name
336335
stream_name
337336
position
338-
raise_on_timeout: Whether to raise an exception if we time out
339-
waiting for the updates, or if we log an error and return.
340337
"""
341338

342339
if instance_name == self._instance_name:
@@ -365,19 +362,23 @@ async def wait_for_stream_position(
365362

366363
# We measure here to get in flight counts and average waiting time.
367364
with Measure(self._clock, "repl.wait_for_stream_position"):
368-
logger.info("Waiting for repl stream %r to reach %s", stream_name, position)
365+
logger.info(
366+
"Waiting for repl stream %r to reach %s (%s)",
367+
stream_name,
368+
position,
369+
instance_name,
370+
)
369371
try:
370372
await make_deferred_yieldable(deferred)
371373
except defer.TimeoutError:
372374
logger.error("Timed out waiting for stream %s", stream_name)
373-
374-
if raise_on_timeout:
375-
raise
376-
377375
return
378376

379377
logger.info(
380-
"Finished waiting for repl stream %r to reach %s", stream_name, position
378+
"Finished waiting for repl stream %r to reach %s (%s)",
379+
stream_name,
380+
position,
381+
instance_name,
381382
)
382383

383384
def stop_pusher(self, user_id: str, app_id: str, pushkey: str) -> None:

0 commit comments

Comments
 (0)