Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

txn being redefined in for loop as we are iterating over it #10739

@MadLittleMods

Description

@MadLittleMods

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.

#10734

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.

for auth_id, event_type, state_key, chain_id, sequence_number in txn:
event_to_types[auth_id] = (event_type, state_key)
if chain_id is None:
# No chain ID, so the event was persisted out of band.
# We add to list of events to calculate auth chains for.
events_to_calc_chain_id_for.add(auth_id)
event_to_auth_chain[auth_id] = db_pool.simple_select_onecol_txn(
txn,

Linting

Maybe we should disallow iterating over txn directly in favor of using txn.fetchall()

Metadata

Metadata

Assignees

Labels

S-MinorBlocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions