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
2d3b4f42
Commit
2d3b4f42
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Move deviceinbox's bg updates to a dedicated store
parent
88957199
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/deviceinbox.py
+22
-15
22 additions, 15 deletions
synapse/storage/deviceinbox.py
with
22 additions
and
15 deletions
synapse/storage/deviceinbox.py
+
22
−
15
View file @
2d3b4f42
...
...
@@ -208,11 +208,11 @@ class DeviceInboxWorkerStore(SQLBaseStore):
)
class
DeviceInbox
Store
(
DeviceInboxWorker
Store
,
BackgroundUpdateStore
):
class
DeviceInbox
BackgroundUpdate
Store
(
BackgroundUpdateStore
):
DEVICE_INBOX_STREAM_ID
=
"
device_inbox_stream_drop
"
def
__init__
(
self
,
db_conn
,
hs
):
super
(
DeviceInboxStore
,
self
).
__init__
(
db_conn
,
hs
)
super
(
DeviceInbox
BackgroundUpdate
Store
,
self
).
__init__
(
db_conn
,
hs
)
self
.
register_background_index_update
(
"
device_inbox_stream_index
"
,
...
...
@@ -225,6 +225,26 @@ class DeviceInboxStore(DeviceInboxWorkerStore, BackgroundUpdateStore):
self
.
DEVICE_INBOX_STREAM_ID
,
self
.
_background_drop_index_device_inbox
)
@defer.inlineCallbacks
def
_background_drop_index_device_inbox
(
self
,
progress
,
batch_size
):
def
reindex_txn
(
conn
):
txn
=
conn
.
cursor
()
txn
.
execute
(
"
DROP INDEX IF EXISTS device_inbox_stream_id
"
)
txn
.
close
()
yield
self
.
runWithConnection
(
reindex_txn
)
yield
self
.
_end_background_update
(
self
.
DEVICE_INBOX_STREAM_ID
)
return
1
class
DeviceInboxStore
(
DeviceInboxWorkerStore
,
DeviceInboxBackgroundUpdateStore
):
DEVICE_INBOX_STREAM_ID
=
"
device_inbox_stream_drop
"
def
__init__
(
self
,
db_conn
,
hs
):
super
(
DeviceInboxStore
,
self
).
__init__
(
db_conn
,
hs
)
# Map of (user_id, device_id) to the last stream_id that has been
# deleted up to. This is so that we can no op deletions.
self
.
_last_device_delete_cache
=
ExpiringCache
(
...
...
@@ -435,16 +455,3 @@ class DeviceInboxStore(DeviceInboxWorkerStore, BackgroundUpdateStore):
return
self
.
runInteraction
(
"
get_all_new_device_messages
"
,
get_all_new_device_messages_txn
)
@defer.inlineCallbacks
def
_background_drop_index_device_inbox
(
self
,
progress
,
batch_size
):
def
reindex_txn
(
conn
):
txn
=
conn
.
cursor
()
txn
.
execute
(
"
DROP INDEX IF EXISTS device_inbox_stream_id
"
)
txn
.
close
()
yield
self
.
runWithConnection
(
reindex_txn
)
yield
self
.
_end_background_update
(
self
.
DEVICE_INBOX_STREAM_ID
)
return
1
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