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
Stop getting missing prev_events after we already know their signature is invalid
#13816
Merged
MadLittleMods
merged 40 commits into
develop
from
madlittlemods/13622-13700-stop-getting-state-ids-after-missing-prev-event-if-we-tried-to-get-this-event-recently
Oct 15, 2022
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
924ae2b
Track when the pulled event signature fails
MadLittleMods d240aeb
Add changelog
MadLittleMods cfb4e88
Fix reference
MadLittleMods 9b390a3
Stop getting missing prev_events after we already know their signatur…
MadLittleMods 3d8507d
Merge branch 'develop' into madlittlemods/13700-track-when-event-sign…
MadLittleMods 88a75cf
Use callback pattern to record signature failures
MadLittleMods d29ac0b
Add docstring
MadLittleMods 14e39ee
Record failure from get_pdu and add test
MadLittleMods 7898371
Be more selective about which errors to care about
MadLittleMods 43f1d1a
Merge branch 'develop' into madlittlemods/13700-track-when-event-sign…
MadLittleMods e32b901
Merge branch 'madlittlemods/13700-track-when-event-signature-fails' i…
MadLittleMods 83feb1b
Merge branch 'develop' into madlittlemods/13700-track-when-event-sign…
MadLittleMods 7d102e8
Merge branch 'develop' into madlittlemods/13700-track-when-event-sign…
MadLittleMods 81410b6
Merge branch 'madlittlemods/13700-track-when-event-signature-fails' i…
MadLittleMods 958fd3b
Merge branch 'develop' into madlittlemods/13622-13700-stop-getting-st…
MadLittleMods e24db41
Weird name and add tests
MadLittleMods f853e78
Add changelog
MadLittleMods 43fb6b8
Bail early and fix lints
MadLittleMods 03f23b7
Add integration test with backfill
MadLittleMods 99d3e79
Fix lints and better message
MadLittleMods f11f5b5
Fix test description
MadLittleMods 6878faa
Fix test descriptions
MadLittleMods f3b443d
Scratch debug changes
MadLittleMods d135d41
Stop cascading backoff errors
MadLittleMods 4effca9
Remove scratch changes
MadLittleMods e3cc054
Use custom FederationPullAttemptBackoffError
MadLittleMods 74f9e03
Fix test to reflect no more cascade
MadLittleMods 0b900e1
Better comments from what I've gathered
MadLittleMods 3cb2826
Clarify which error in comments
MadLittleMods 5f313df
Add some clarification to the test comment
MadLittleMods 02e6bdd
Merge branch 'develop' into madlittlemods/13622-13700-stop-getting-st…
MadLittleMods 7f4fdd2
Not a SynapseError
MadLittleMods 89ffbcb
Make sure usages of _compute_event_context_with_maybe_missing_prevs h…
MadLittleMods 354f682
Remove double "recently"
MadLittleMods e0b0447
Do the calculation in Python because it's more clear when we need res…
MadLittleMods e72c4e5
Use built-in select many function
MadLittleMods 4e08039
No need for txn
MadLittleMods b060652
Rename function to reflect functionality
MadLittleMods b1a0c1b
Fix test description to make it accurate
MadLittleMods bccd802
Use more standard string interpolation with `logger`
MadLittleMods 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 @@ | ||
| Stop fetching missing `prev_events` after we already know their signature is invalid. |
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 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1501,6 +1501,12 @@ async def record_event_failed_pull_attempt( | |||||||||||||||||||||||||||||||||
| event_id: The event that failed to be fetched or processed | ||||||||||||||||||||||||||||||||||
| cause: The error message or reason that we failed to pull the event | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| logger.debug( | ||||||||||||||||||||||||||||||||||
| "record_event_failed_pull_attempt room_id=%s, event_id=%s, cause=%s", | ||||||||||||||||||||||||||||||||||
| room_id, | ||||||||||||||||||||||||||||||||||
| event_id, | ||||||||||||||||||||||||||||||||||
| cause, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| await self.db_pool.runInteraction( | ||||||||||||||||||||||||||||||||||
| "record_event_failed_pull_attempt", | ||||||||||||||||||||||||||||||||||
| self._record_event_failed_pull_attempt_upsert_txn, | ||||||||||||||||||||||||||||||||||
|
|
@@ -1530,6 +1536,54 @@ def _record_event_failed_pull_attempt_upsert_txn( | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| txn.execute(sql, (room_id, event_id, 1, self._clock.time_msec(), cause)) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| @trace | ||||||||||||||||||||||||||||||||||
| async def get_event_ids_to_not_pull_from_backoff( | ||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||
| room_id: str, | ||||||||||||||||||||||||||||||||||
| event_ids: Collection[str], | ||||||||||||||||||||||||||||||||||
| ) -> List[str]: | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| Filter down the events to ones that we've failed to pull before recently. Uses | ||||||||||||||||||||||||||||||||||
| exponential backoff. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||
| room_id: The room that the events belong to | ||||||||||||||||||||||||||||||||||
| event_ids: A list of events to filter down | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||||||||
| List of event_ids that should not be attempted to be pulled | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| event_failed_pull_attempts = await self.db_pool.simple_select_many_batch( | ||||||||||||||||||||||||||||||||||
| table="event_failed_pull_attempts", | ||||||||||||||||||||||||||||||||||
| column="event_id", | ||||||||||||||||||||||||||||||||||
| iterable=event_ids, | ||||||||||||||||||||||||||||||||||
| keyvalues={}, | ||||||||||||||||||||||||||||||||||
| retcols=( | ||||||||||||||||||||||||||||||||||
| "event_id", | ||||||||||||||||||||||||||||||||||
| "last_attempt_ts", | ||||||||||||||||||||||||||||||||||
| "num_attempts", | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| desc="get_event_ids_to_not_pull_from_backoff", | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| current_time = self._clock.time_msec() | ||||||||||||||||||||||||||||||||||
| return [ | ||||||||||||||||||||||||||||||||||
| event_failed_pull_attempt["event_id"] | ||||||||||||||||||||||||||||||||||
| for event_failed_pull_attempt in event_failed_pull_attempts | ||||||||||||||||||||||||||||||||||
| # Exponential back-off (up to the upper bound) so we don't try to | ||||||||||||||||||||||||||||||||||
| # pull the same event over and over. ex. 2hr, 4hr, 8hr, 16hr, etc. | ||||||||||||||||||||||||||||||||||
| if current_time | ||||||||||||||||||||||||||||||||||
| < event_failed_pull_attempt["last_attempt_ts"] | ||||||||||||||||||||||||||||||||||
| + ( | ||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||
| ** min( | ||||||||||||||||||||||||||||||||||
| event_failed_pull_attempt["num_attempts"], | ||||||||||||||||||||||||||||||||||
| BACKFILL_EVENT_EXPONENTIAL_BACKOFF_MAXIMUM_DOUBLING_STEPS, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| * BACKFILL_EVENT_EXPONENTIAL_BACKOFF_STEP_MILLISECONDS | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1573
to
+1584
Contributor
Author
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. ^ Sanity check appreciated here to make sure we're doing the equivalent of synapse/synapse/storage/databases/main/event_federation.py Lines 842 to 857 in b6baa46
|
||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async def get_missing_events( | ||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||
| room_id: str, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Oops, something went wrong.
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.