-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Process previously failed backfill events in the background #15585
Changes from all commits
fd26164
c5dc746
8fc47d8
b5d95f7
ebc93be
e13f5a9
70f5911
45934fe
b1998d7
93de856
631d7db
beeccc3
7eabc60
7583c2c
e101318
899fc34
b5aec4f
6edd126
d4b8ff7
6a0ec9d
d843557
75bec52
c4e1533
ec230a3
22a69be
65febed
6474b4e
15527f7
d59615f
95ffa7c
50acf6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Process previously failed backfill events in the background to avoid blocking requests for something that is bound to fail again. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -664,6 +664,101 @@ async def get_room_state( | |
StoreError, | ||
) | ||
|
||
def test_backfill_process_previously_failed_pull_attempt_event_in_the_background( | ||
self, | ||
) -> None: | ||
""" | ||
Sanity check that events are still processed even if it is in the background | ||
for events that already have failed pull attempts. | ||
""" | ||
OTHER_USER = f"@user:{self.OTHER_SERVER_NAME}" | ||
main_store = self.hs.get_datastores().main | ||
|
||
# Create the room | ||
user_id = self.register_user("kermit", "test") | ||
tok = self.login("kermit", "test") | ||
room_id = self.helper.create_room_as(room_creator=user_id, tok=tok) | ||
room_version = self.get_success(main_store.get_room_version(room_id)) | ||
|
||
# Allow the remote user to send state events | ||
self.helper.send_state( | ||
room_id, | ||
"m.room.power_levels", | ||
{"events_default": 0, "state_default": 0}, | ||
tok=tok, | ||
) | ||
|
||
# Add the remote user to the room | ||
member_event = self.get_success( | ||
event_injection.inject_member_event(self.hs, room_id, OTHER_USER, "join") | ||
) | ||
|
||
initial_state_map = self.get_success( | ||
main_store.get_partial_current_state_ids(room_id) | ||
) | ||
|
||
auth_event_ids = [ | ||
initial_state_map[("m.room.create", "")], | ||
initial_state_map[("m.room.power_levels", "")], | ||
member_event.event_id, | ||
] | ||
|
||
# Create a regular event that should process | ||
pulled_event = make_event_from_dict( | ||
self.add_hashes_and_signatures_from_other_server( | ||
{ | ||
"type": "test_regular_type", | ||
"room_id": room_id, | ||
"sender": OTHER_USER, | ||
"prev_events": [ | ||
member_event.event_id, | ||
], | ||
"auth_events": auth_event_ids, | ||
"origin_server_ts": 1, | ||
"depth": 12, | ||
"content": {"body": "pulled_event"}, | ||
} | ||
), | ||
room_version, | ||
) | ||
|
||
# Record a failed pull attempt for this event which will cause us to backfill it | ||
# in the background from here on out. | ||
self.get_success( | ||
main_store.record_event_failed_pull_attempt( | ||
room_id, pulled_event.event_id, "fake cause" | ||
) | ||
) | ||
|
||
# We expect an outbound request to /backfill, so stub that out | ||
self.mock_federation_transport_client.backfill.return_value = make_awaitable( | ||
{ | ||
"origin": self.OTHER_SERVER_NAME, | ||
"origin_server_ts": 123, | ||
"pdus": [ | ||
pulled_event.get_pdu_json(), | ||
], | ||
} | ||
) | ||
|
||
# The function under test: try to backfill and process the pulled event | ||
with LoggingContext("test"): | ||
self.get_success( | ||
self.hs.get_federation_event_handler().backfill( | ||
self.OTHER_SERVER_NAME, | ||
room_id, | ||
limit=1, | ||
extremities=["$some_extremity"], | ||
) | ||
) | ||
|
||
# Ensure `run_as_background_process(...)` has a chance to run (essentially | ||
# `wait_for_background_processes()`) | ||
self.reactor.pump((0.1,)) | ||
Comment on lines
+755
to
+757
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. Continuing from previous comment, The test passes even without this But I want to ensure that this test is robust to any work that may happen in |
||
|
||
# Make sure we processed and persisted the pulled event | ||
self.get_success(main_store.get_event(pulled_event.event_id, allow_none=False)) | ||
|
||
def test_process_pulled_event_with_rejected_missing_state(self) -> None: | ||
"""Ensure that we correctly handle pulled events with missing state containing a | ||
rejected state event | ||
|
Uh oh!
There was an error while loading. Please reload this page.