This repository has been 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
Don't go into federation catch up mode so easily #9561
Merged
+190
−159
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f4ec26d
Don't go into federation catch up mode so easily
erikjohnston 52510c5
Newsfile
erikjohnston 7becd94
Name parameters in function call for clarity
erikjohnston 454da8a
Use a flag to mark if there is new stuff, rather than an atomic section
erikjohnston 4f04ecc
Have send_new_transaction always raise on error
erikjohnston d6effcf
Move pulling from queues to a async context manager
erikjohnston d0bf228
Requeue events for sending if transaction fails
erikjohnston b90c517
Fix tests
erikjohnston 216d12d
Review comments
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 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 @@ | ||
Increase the threshold before which outbound federation to a server goes into "catch up" mode, which is expensive for the remote server to handle. |
This file contains 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 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 |
---|---|---|
|
@@ -69,15 +69,12 @@ async def send_new_transaction( | |
destination: str, | ||
pdus: List[EventBase], | ||
edus: List[Edu], | ||
) -> bool: | ||
) -> None: | ||
""" | ||
Args: | ||
destination: The destination to send to (e.g. 'example.org') | ||
pdus: In-order list of PDUs to send | ||
edus: List of EDUs to send | ||
|
||
Returns: | ||
True iff the transaction was successful | ||
Comment on lines
-79
to
-80
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. Is it worth mentioning what this raises while we're here? 😄 |
||
""" | ||
|
||
# Make a transaction-sending opentracing span. This span follows on from | ||
|
@@ -96,8 +93,6 @@ async def send_new_transaction( | |
edu.strip_context() | ||
|
||
with start_active_span_follows_from("send_transaction", span_contexts): | ||
success = True | ||
|
||
logger.debug("TX [%s] _attempt_new_transaction", destination) | ||
|
||
txn_id = str(self._next_txn_id) | ||
|
@@ -152,44 +147,29 @@ def json_data_cb(): | |
response = await self._transport_layer.send_transaction( | ||
transaction, json_data_cb | ||
) | ||
code = 200 | ||
except HttpResponseException as e: | ||
code = e.code | ||
response = e.response | ||
|
||
if e.code in (401, 404, 429) or 500 <= e.code: | ||
logger.info( | ||
"TX [%s] {%s} got %d response", destination, txn_id, code | ||
) | ||
raise e | ||
|
||
logger.info("TX [%s] {%s} got %d response", destination, txn_id, code) | ||
|
||
if code == 200: | ||
for e_id, r in response.get("pdus", {}).items(): | ||
if "error" in r: | ||
logger.warning( | ||
"TX [%s] {%s} Remote returned error for %s: %s", | ||
destination, | ||
txn_id, | ||
e_id, | ||
r, | ||
) | ||
else: | ||
for p in pdus: | ||
set_tag(tags.ERROR, True) | ||
|
||
logger.info("TX [%s] {%s} got %d response", destination, txn_id, code) | ||
raise | ||
|
||
logger.info("TX [%s] {%s} got 200 response", destination, txn_id) | ||
|
||
for e_id, r in response.get("pdus", {}).items(): | ||
if "error" in r: | ||
logger.warning( | ||
"TX [%s] {%s} Failed to send event %s", | ||
"TX [%s] {%s} Remote returned error for %s: %s", | ||
destination, | ||
txn_id, | ||
p.event_id, | ||
e_id, | ||
r, | ||
) | ||
success = False | ||
|
||
if success and pdus and destination in self._federation_metrics_domains: | ||
if pdus and destination in self._federation_metrics_domains: | ||
last_pdu = pdus[-1] | ||
last_pdu_ts_metric.labels(server_name=destination).set( | ||
last_pdu.origin_server_ts / 1000 | ||
) | ||
|
||
set_tag(tags.ERROR, not success) | ||
return success |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but I wonder if we should try to log the event IDs on one line here instead of 50. In another PR though.