Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
24103355
Commit
24103355
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Use upsert when updating destination retry interval
parent
356ed043
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/transactions.py
+20
-0
20 additions, 0 deletions
synapse/storage/transactions.py
with
20 additions
and
0 deletions
synapse/storage/transactions.py
+
20
−
0
View file @
24103355
...
...
@@ -196,6 +196,26 @@ class TransactionStore(SQLBaseStore):
def
_set_destination_retry_timings
(
self
,
txn
,
destination
,
retry_last_ts
,
retry_interval
):
if
self
.
database_engine
.
can_native_upsert
:
# Upsert retry time interval if retry_interval is zero (i.e. we're
# resetting it) or greater than the existing retry interval.
sql
=
"""
INSERT INTO destinations (destination, retry_last_ts, retry_interval)
VALUES (?, ?, ?)
ON CONFLICT (destination) DO UPDATE SET
retry_last_ts = EXCLUDED.retry_last_ts,
retry_interval = EXCLUDED.retry_interval
WHERE
EXCLUDED.retry_interval = 0
OR destinations.retry_interval < EXCLUDED.retry_interval
"""
txn
.
execute
(
sql
,
(
destination
,
retry_last_ts
,
retry_interval
))
return
self
.
database_engine
.
lock_table
(
txn
,
"
destinations
"
)
# We need to be careful here as the data may have changed from under us
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment