From 9be577c4701414cc5ddc75368af93718083f0144 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 5 Oct 2020 15:22:24 +0100 Subject: [PATCH] Use autocommit when fetching sequence values --- synapse/storage/util/id_generators.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py index ba72b8790b54..bd32eea9d497 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py @@ -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