-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Room batch: fix up handling of unknown prev_event_ids #12316
Changes from all commits
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 @@ | ||
Avoid trying to calculate the state at outlier events. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,19 @@ async def on_POST( | |
errcode=Codes.INVALID_PARAM, | ||
) | ||
|
||
# Make sure that the prev_event_ids exist and aren't outliers - ie, they are | ||
# regular parts of the room DAG where we know the state. | ||
non_outlier_prev_events = await self.store.have_events_in_timeline( | ||
prev_event_ids_from_query | ||
) | ||
for prev_event_id in prev_event_ids_from_query: | ||
if prev_event_id not in non_outlier_prev_events: | ||
raise SynapseError( | ||
HTTPStatus.BAD_REQUEST, | ||
"prev_event %s does not exist, or is an outlier" % (prev_event_id,), | ||
errcode=Codes.INVALID_PARAM, | ||
) | ||
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. We should add a test for this case, 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 is surprising that it's necessary. Is I'd expect 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.
currently, that's the case. I'm seeking to change it in #12191. |
||
|
||
# For the event we are inserting next to (`prev_event_ids_from_query`), | ||
# find the most recent state events that allowed that message to be | ||
# sent. We will use that as a base to auth our historical messages | ||
|
@@ -131,14 +144,6 @@ async def on_POST( | |
prev_event_ids_from_query | ||
) | ||
|
||
if not state_event_ids: | ||
raise SynapseError( | ||
HTTPStatus.BAD_REQUEST, | ||
"No auth events found for given prev_event query parameter. The prev_event=%s probably does not exist." | ||
% prev_event_ids_from_query, | ||
errcode=Codes.INVALID_PARAM, | ||
) | ||
|
||
state_event_ids_at_start = [] | ||
# Create and persist all of the state events that float off on their own | ||
# before the batch. These will most likely be all of the invite/member | ||
|
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.
It's used as the place we're inserting next to. Which means, inheriting the
depth
and state at that point in time.Batches of history aren't connected together in the DAG by
prev_event_id
. There is only a loose connection from thebatch
event of the next batch pointing back at theinsertion
event in the previous batch. But it's also possible to derive the same information from the previous batch but it just hasn't been that way. It can change.