You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Spurred on by the note in #10734 about txn being redefined in for loop as we are iterating over it.
We were originally iterating over txn, which can work, but as txn was being used to run a
simple_delete operation inside the loop, it was actually being redefined mid-loop.
I was curious if there were other cases in the codebase, so I searched for in txn: and found one more case. It looks like this would cause a problem if there was an event where the event_auth_chains -> chain_id was not defined.
Oh, good catch. I think its unlikely for that case to ever be hit in practice as its really only used to handle out of band memberships and we likely only have one of those per room anyway. We should still fix it though!
Maybe we should disallow iterating over txn directly in favor of using txn.fetchall()
Using txn can be considerably faster when there's a lot of rows to process, so I'm not super keen on forbidding it entirely. Ideally mypy would have a way to annotate that we can't reuse txn here, but I don't think its possible.
Spurred on by the note in #10734 about
txn
being redefined in for loop as we are iterating over it.I was curious if there were other cases in the codebase, so I searched for
in txn:
and found one more case. It looks like this would cause a problem if there was an event where theevent_auth_chains
->chain_id
was not defined.synapse/synapse/storage/databases/main/events.py
Lines 578 to 588 in c586d68
Linting
Maybe we should disallow iterating over
txn
directly in favor of usingtxn.fetchall()
The text was updated successfully, but these errors were encountered: