mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-13 15:52:51 -04:00
Stop reading from event_edges.room_id
. (#12914)
event_edges.room_id is implied by the event id, so there is no need to join on the room id.
This commit is contained in:
parent
1e453053cb
commit
5e17922ef7
4 changed files with 26 additions and 28 deletions
|
@ -1928,23 +1928,6 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
LIMIT 1
|
||||
"""
|
||||
|
||||
# Check to see whether the event in question is already referenced
|
||||
# by another event. If we don't see any edges, we're next to a
|
||||
# forward gap.
|
||||
forward_edge_query = """
|
||||
SELECT 1 FROM event_edges
|
||||
/* Check to make sure the event referencing our event in question is not rejected */
|
||||
LEFT JOIN rejections ON event_edges.event_id = rejections.event_id
|
||||
WHERE
|
||||
event_edges.room_id = ?
|
||||
AND event_edges.prev_event_id = ?
|
||||
/* It's not a valid edge if the event referencing our event in
|
||||
* question is rejected.
|
||||
*/
|
||||
AND rejections.event_id IS NULL
|
||||
LIMIT 1
|
||||
"""
|
||||
|
||||
# We consider any forward extremity as the latest in the room and
|
||||
# not a forward gap.
|
||||
#
|
||||
|
@ -1954,16 +1937,30 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
# is useless. The new latest messages will just be federated as
|
||||
# usual.
|
||||
txn.execute(forward_extremity_query, (event.room_id, event.event_id))
|
||||
forward_extremities = txn.fetchall()
|
||||
if len(forward_extremities):
|
||||
if txn.fetchone():
|
||||
return False
|
||||
|
||||
# Check to see whether the event in question is already referenced
|
||||
# by another event. If we don't see any edges, we're next to a
|
||||
# forward gap.
|
||||
forward_edge_query = """
|
||||
SELECT 1 FROM event_edges
|
||||
/* Check to make sure the event referencing our event in question is not rejected */
|
||||
LEFT JOIN rejections ON event_edges.event_id = rejections.event_id
|
||||
WHERE
|
||||
event_edges.prev_event_id = ?
|
||||
/* It's not a valid edge if the event referencing our event in
|
||||
* question is rejected.
|
||||
*/
|
||||
AND rejections.event_id IS NULL
|
||||
LIMIT 1
|
||||
"""
|
||||
|
||||
# If there are no forward edges to the event in question (another
|
||||
# event hasn't referenced this event in their prev_events), then we
|
||||
# assume there is a forward gap in the history.
|
||||
txn.execute(forward_edge_query, (event.room_id, event.event_id))
|
||||
forward_edges = txn.fetchall()
|
||||
if not len(forward_edges):
|
||||
txn.execute(forward_edge_query, (event.event_id,))
|
||||
if not txn.fetchone():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue