1
0

Reorder args so *args, **kwargs comes at the end

This commit is contained in:
David Robertson
2022-10-01 22:20:14 +01:00
parent c7ee636762
commit e67cd89e7b
8 changed files with 18 additions and 21 deletions
+3 -8
View File
@@ -806,21 +806,16 @@ class DatabasePool:
**kwargs: Any,
) -> R:
return await self.runInteraction_advanced(
desc,
func,
*args,
db_autocommit=False,
isolation_level=None,
**kwargs,
desc, False, None, func, *args, **kwargs
)
async def runInteraction_advanced(
self,
desc: str,
db_autocommit: bool,
isolation_level: Optional[int],
func: Callable[..., R],
*args: Any,
db_autocommit: bool = False,
isolation_level: Optional[int] = None,
**kwargs: Any,
) -> R:
"""Starts a transaction on the database and runs a given function
@@ -1084,11 +1084,12 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore, CacheInvalidationWorker
claim_row = await self.db_pool.runInteraction_advanced(
"claim_e2e_one_time_keys",
db_autocommit,
None,
_claim_e2e_one_time_key,
user_id,
device_id,
algorithm,
db_autocommit=db_autocommit,
)
if claim_row:
device_results = results.setdefault(user_id, {}).setdefault(
@@ -1691,8 +1691,9 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
return await self.db_pool.runInteraction_advanced(
"remove_received_event_from_staging",
_remove_received_event_from_staging_txn,
db_autocommit=True,
isolation_level=None,
func=_remove_received_event_from_staging_txn,
)
else:
+2 -3
View File
@@ -164,10 +164,9 @@ class LockStore(SQLBaseStore):
did_lock = await self.db_pool.runInteraction_advanced(
"try_acquire_lock",
_try_acquire_lock_txn,
# We can autocommit here as we're executing a single query, this
# will avoid serialization errors.
db_autocommit=True,
isolation_level=None,
func=_try_acquire_lock_txn,
)
if not did_lock:
return None
@@ -327,9 +327,10 @@ class PurgeEventsStore(StateGroupWorkerStore, CacheInvalidationWorkerStore):
state_groups_to_delete = await self.db_pool.runInteraction_advanced(
"purge_room",
self._purge_room_txn,
room_id=room_id,
False,
isolation_level=IsolationLevel.READ_COMMITTED,
func=self._purge_room_txn,
room_id=room_id,
)
state_groups_to_delete.extend(
+2 -4
View File
@@ -779,6 +779,8 @@ class ReceiptsWorkerStore(SQLBaseStore):
async with self._receipts_id_gen.get_next() as stream_id: # type: ignore[attr-defined]
event_ts = await self.db_pool.runInteraction_advanced(
"insert_linearized_receipt",
False,
IsolationLevel.READ_COMMITTED,
self._insert_linearized_receipt_txn,
room_id,
receipt_type,
@@ -787,10 +789,6 @@ class ReceiptsWorkerStore(SQLBaseStore):
thread_id,
data,
stream_id=stream_id,
# Read committed is actually beneficial here because we check for a receipt with
# greater stream order, and checking the very latest data at select time is better
# than the data at transaction start time.
isolation_level=IsolationLevel.READ_COMMITTED,
)
# If the receipt was older than the currently persisted one, nothing to do.
@@ -223,12 +223,13 @@ class TransactionWorkerStore(CacheInvalidationWorkerStore):
await self.db_pool.runInteraction_advanced(
"set_destination_retry_timings",
True,
None,
self._set_destination_retry_timings_native,
destination,
failure_ts,
retry_last_ts,
retry_interval,
db_autocommit=True, # Safe as it's a single upsert
)
def _set_destination_retry_timings_native(
+2 -1
View File
@@ -820,8 +820,9 @@ class _MultiWriterCtxManager:
if self.id_gen._writers:
await self.id_gen._db.runInteraction_advanced(
"MultiWriterIdGenerator._update_table",
self.id_gen._update_stream_positions_table_txn,
db_autocommit=True,
isolation_level=None,
func=self.id_gen._update_stream_positions_table_txn,
)
return False