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

Populate rooms.creator field for easy lookup #10697

Merged
merged 12 commits into from
Sep 1, 2021
3 changes: 2 additions & 1 deletion synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,9 +1370,10 @@ def _background_populate_rooms_creator_column_txn(txn: LoggingTransaction):
"""

txn.execute(sql, (last_room_id, batch_size))
room_id_to_create_event_results = txn.fetchall()

new_last_room_id = ""
for room_id, event_json in txn:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I was also running into something similar to #10734

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

And in this case, we're iterating over txn and doing a simple_update_txn 🤔

for room_id, event_json in room_id_to_create_event_results:
event_dict = db_to_json(event_json)

creator = event_dict.get("content").get(EventContentFields.ROOM_CREATOR)
Expand Down