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

Commit

Permalink
Remove unused store method _set_destination_retry_timings_emulated. (
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Mar 14, 2023
1 parent de92fb6 commit d0fe417
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 54 deletions.
1 change: 1 addition & 0 deletions changelog.d/15266.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused store method `_set_destination_retry_timings_emulated`.
56 changes: 2 additions & 54 deletions synapse/storage/databases/main/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ 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,
retry_interval,
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,
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit d0fe417

Please sign in to comment.