Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
0d3fa1ac
Commit
0d3fa1ac
authored
10 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
add a write-through cache on the retry schedule
parent
9c43b258
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/transactions.py
+15
-4
15 additions, 4 deletions
synapse/storage/transactions.py
with
15 additions
and
4 deletions
synapse/storage/transactions.py
+
15
−
4
View file @
0d3fa1ac
...
...
@@ -25,6 +25,9 @@ logger = logging.getLogger(__name__)
class
TransactionStore
(
SQLBaseStore
):
"""
A collection of queries for handling PDUs.
"""
# a write-through cache of DestinationsTable.EntryType indexed by destination string
destination_retry_cache
=
{}
def
get_received_txn_response
(
self
,
transaction_id
,
origin
):
"""
For an incoming transaction from a given origin, check if we have
...
...
@@ -213,10 +216,11 @@ class TransactionStore(SQLBaseStore):
Returns:
None if not retrying
tuple: (retry_last_ts, retry_interval)
retry_ts: time of last retry attempt in unix epoch ms
retry_interval: how long until next retry in ms
Otherwise a DestinationsTable.EntryType for the retry scheme
"""
if
self
.
destination_retry_cache
[
destination
]:
return
self
.
destination_retry_cache
[
destination
]
return
self
.
runInteraction
(
"
get_destination_retry_timings
"
,
self
.
_get_destination_retry_timings
,
destination
)
...
...
@@ -225,7 +229,7 @@ class TransactionStore(SQLBaseStore):
query
=
DestinationsTable
.
select_statement
(
"
destination = ?
"
)
txn
.
execute
(
query
,
(
destination
,))
result
=
DestinationsTable
.
decode_single_result
(
txn
.
fetchone
())
if
result
and
result
[
0
]
>
0
:
if
result
and
result
.
retry_last_ts
>
0
:
return
result
else
:
return
None
...
...
@@ -239,6 +243,12 @@ class TransactionStore(SQLBaseStore):
retry_last_ts (int) - time of last retry attempt in unix epoch ms
retry_interval (int) - how long until next retry in ms
"""
self
.
destination_retry_cache
[
destination
]
=
(
DestinationsTable
.
EntryType
(
destination
,
retry_last_ts
,
retry_interval
)
)
# xxx: we could chose to not bother persisting this if our cache things this is a NOOP
return
self
.
runInteraction
(
"
set_destination_retry_timings
"
,
self
.
_set_destination_retry_timings
,
destination
,
retry_last_ts
,
retry_interval
)
...
...
@@ -260,6 +270,7 @@ class TransactionStore(SQLBaseStore):
Returns:
list: A list of `DestinationsTable.EntryType`
"""
return
self
.
runInteraction
(
"
get_destinations_needing_retry
"
,
self
.
_get_destinations_needing_retry
...
...
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