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

Commit

Permalink
Use autocommit when fetching sequence values
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Oct 5, 2020
1 parent 201d2da commit 9be577c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,13 @@ class _MultiWriterCtxManager:
stream_ids = attr.ib(type=List[int], factory=list)

async def __aenter__(self) -> Union[int, List[int]]:
# It's safe to run this in autocommit mode as fetching values from a
# sequence ignores transaction semantics anyway.
self.stream_ids = await self.id_gen._db.runInteraction(
"_load_next_mult_id",
self.id_gen._load_next_mult_id_txn,
self.multiple_ids or 1,
db_autocommit=True,
)

# Assert the fetched ID is actually greater than any ID we've already
Expand Down

0 comments on commit 9be577c

Please sign in to comment.