From 69c059e18415276aa8f8c0a1e1e2cb1c4884c816 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 14 Mar 2023 16:00:46 +0000 Subject: [PATCH 1/3] Remove unused _set_destination_retry_timings_emulated --- .../storage/databases/main/transactions.py | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/synapse/storage/databases/main/transactions.py b/synapse/storage/databases/main/transactions.py index 6d72bd9f67f2..23d20fc1122c 100644 --- a/synapse/storage/databases/main/transactions.py +++ b/synapse/storage/databases/main/transactions.py @@ -266,58 +266,6 @@ def _set_destination_retry_timings_native( txn, self.get_destination_retry_timings, (destination,) ) - def _set_destination_retry_timings_emulated( - self, - txn: LoggingTransaction, - destination: str, - failure_ts: Optional[int], - retry_last_ts: int, - retry_interval: int, - ) -> None: - self.database_engine.lock_table(txn, "destinations") - - # We need to be careful here as the data may have changed from under us - # due to a worker setting the timings. - - prev_row = self.db_pool.simple_select_one_txn( - txn, - table="destinations", - keyvalues={"destination": destination}, - retcols=("failure_ts", "retry_last_ts", "retry_interval"), - allow_none=True, - ) - - if not prev_row: - self.db_pool.simple_insert_txn( - txn, - table="destinations", - values={ - "destination": destination, - "failure_ts": failure_ts, - "retry_last_ts": retry_last_ts, - "retry_interval": retry_interval, - }, - ) - elif ( - retry_interval == 0 - or prev_row["retry_interval"] is None - or prev_row["retry_interval"] < retry_interval - ): - self.db_pool.simple_update_one_txn( - txn, - "destinations", - keyvalues={"destination": destination}, - updatevalues={ - "failure_ts": failure_ts, - "retry_last_ts": retry_last_ts, - "retry_interval": retry_interval, - }, - ) - - self._invalidate_cache_and_stream( - txn, self.get_destination_retry_timings, (destination,) - ) - async def store_destination_rooms_entries( self, destinations: Iterable[str], From 6c146dbeb6b693e3a0da5af121e42b318bb4d74b Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 14 Mar 2023 16:00:56 +0000 Subject: [PATCH 2/3] Rename the _native one to _txn as it's clearer anyway --- synapse/storage/databases/main/transactions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/transactions.py b/synapse/storage/databases/main/transactions.py index 23d20fc1122c..c3bd36efc9c2 100644 --- a/synapse/storage/databases/main/transactions.py +++ b/synapse/storage/databases/main/transactions.py @@ -224,7 +224,7 @@ async def set_destination_retry_timings( await self.db_pool.runInteraction( "set_destination_retry_timings", - self._set_destination_retry_timings_native, + self._set_destination_retry_timings_txn, destination, failure_ts, retry_last_ts, @@ -232,7 +232,7 @@ async def set_destination_retry_timings( db_autocommit=True, # Safe as it's a single upsert ) - def _set_destination_retry_timings_native( + def _set_destination_retry_timings_txn( self, txn: LoggingTransaction, destination: str, From ee43d70279a37137971665cfeb482caaecb8a65d Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 14 Mar 2023 16:01:35 +0000 Subject: [PATCH 3/3] Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/15266.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15266.misc diff --git a/changelog.d/15266.misc b/changelog.d/15266.misc new file mode 100644 index 000000000000..285b72cdd159 --- /dev/null +++ b/changelog.d/15266.misc @@ -0,0 +1 @@ +Remove unused store method `_set_destination_retry_timings_emulated`. \ No newline at end of file