Filter out auth chain queries that don't exist (#16552)

pull/16678/head
Jason Little 2023-11-22 04:59:16 -06:00 committed by GitHub
parent 8d5c1fe921
commit 460743da16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

1
changelog.d/16552.misc Normal file
View File

@ -0,0 +1 @@
Reduce a little database load while processing state auth chains.

View File

@ -301,6 +301,11 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
# Add the initial set of chains, excluding the sequence corresponding to # Add the initial set of chains, excluding the sequence corresponding to
# initial event. # initial event.
for chain_id, seq_no in event_chains.items(): for chain_id, seq_no in event_chains.items():
# Check if the initial event is the first item in the chain. If so, then
# there is nothing new to add from this chain.
if seq_no == 1:
continue
chains[chain_id] = max(seq_no - 1, chains.get(chain_id, 0)) chains[chain_id] = max(seq_no - 1, chains.get(chain_id, 0))
# Now for each chain we figure out the maximum sequence number reachable # Now for each chain we figure out the maximum sequence number reachable