This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Immediately retry any requests that have backed off when a server comes back online. #12500
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
793cffe
Add a `AwakenableSleeper` class
erikjohnston 3aba59c
Immediate retry any requests that have backed off when a server comes…
erikjohnston fde708b
Newsfile
erikjohnston b1deb3f
Mark remote server as up when we can talk to it
erikjohnston 50bcd88
Fixup
erikjohnston 337d7f6
Merge remote-tracking branch 'origin/develop' into erikj/server_wake_up
erikjohnston 9a0db86
Add tests
erikjohnston 5bb822b
Don't take a copy of the streams
erikjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Immediately retry any requests that have backed off when a server comes back online. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,17 @@ | |
import logging | ||
import random | ||
from types import TracebackType | ||
from typing import Any, Optional, Type | ||
from typing import TYPE_CHECKING, Any, Optional, Type | ||
|
||
import synapse.logging.context | ||
from synapse.api.errors import CodeMessageException | ||
from synapse.storage import DataStore | ||
from synapse.util import Clock | ||
|
||
if TYPE_CHECKING: | ||
from synapse.notifier import Notifier | ||
from synapse.replication.tcp.handler import ReplicationCommandHandler | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# the initial backoff, after the first transaction fails | ||
|
@@ -131,6 +135,8 @@ def __init__( | |
retry_interval: int, | ||
backoff_on_404: bool = False, | ||
backoff_on_failure: bool = True, | ||
notifier: Optional["Notifier"] = None, | ||
replication_client: Optional["ReplicationCommandHandler"] = None, | ||
): | ||
"""Marks the destination as "down" if an exception is thrown in the | ||
context, except for CodeMessageException with code < 500. | ||
|
@@ -160,6 +166,9 @@ def __init__( | |
self.backoff_on_404 = backoff_on_404 | ||
self.backoff_on_failure = backoff_on_failure | ||
|
||
self.notifier = notifier | ||
self.replication_client = replication_client | ||
|
||
def __enter__(self) -> None: | ||
pass | ||
|
||
|
@@ -239,6 +248,19 @@ async def store_retry_timings() -> None: | |
retry_last_ts, | ||
self.retry_interval, | ||
) | ||
|
||
if self.notifier: | ||
# Inform the relevant places that the remote server is back up. | ||
self.notifier.notify_remote_server_up(self.destination) | ||
|
||
if self.replication_client: | ||
# If we're on a worker we try and inform master about this. The | ||
# replication client doesn't hook into the notifier to avoid | ||
# infinite loops where we send a `REMOTE_SERVER_UP` command to | ||
# master, which then echoes it back to us which in turn pokes | ||
# the notifier. | ||
self.replication_client.send_remote_server_up(self.destination) | ||
|
||
Comment on lines
+251
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This path appears to get taken when we fail to contact the remote server too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #16506. |
||
except Exception: | ||
logger.exception("Failed to store destination_retry_timings") | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.