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
Container registry
Model registry
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
Maunium
synapse
Commits
699be7d1
Commit
699be7d1
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix up notif rotation
parent
2fa14fd4
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/event_push_actions.py
+22
-14
22 additions, 14 deletions
synapse/storage/event_push_actions.py
with
22 additions
and
14 deletions
synapse/storage/event_push_actions.py
+
22
−
14
View file @
699be7d1
...
...
@@ -168,19 +168,13 @@ class EventPushActionsStore(SQLBaseStore):
row
=
txn
.
fetchone
()
notify_count
=
row
[
0
]
if
row
else
0
summary_notif_count
=
self
.
_simple_select_one_onecol_txn
(
txn
,
table
=
"
event_push_summary
"
,
keyvalues
=
{
"
user_id
"
:
user_id
,
"
room_id
"
:
room_id
,
},
retcol
=
"
notif_count
"
,
allow_none
=
True
,
)
if
summary_notif_count
:
notify_count
+=
summary_notif_count
txn
.
execute
(
"""
SELECT notif_count FROM event_push_summary
WHERE room_id = ? AND user_id = ? AND stream_ordering > ?
"""
,
(
room_id
,
user_id
,
stream_ordering
,))
rows
=
txn
.
fetchall
()
if
rows
:
notify_count
+=
rows
[
0
][
0
]
# Now get the number of highlights
sql
=
(
...
...
@@ -645,12 +639,20 @@ class EventPushActionsStore(SQLBaseStore):
# We want to make sure that we only ever do this one at a time
self
.
database_engine
.
lock_table
(
txn
,
"
event_push_summary
"
)
old_rotate_stream_ordering
=
self
.
_simple_select_one_onecol_txn
(
txn
,
table
=
"
event_push_summary_stream_ordering
"
,
keyvalues
=
{},
retcol
=
"
stream_ordering
"
,
)
# We don't to try and rotate millions of rows at once, so we cap the
# maximum stream ordering we'll rotate before.
txn
.
execute
(
"""
SELECT stream_ordering FROM event_push_actions
WHERE stream_ordering > ?
ORDER BY stream_ordering ASC LIMIT 1 OFFSET 50000
"""
)
"""
,
(
old_rotate_stream_ordering
,)
)
stream_row
=
txn
.
fetchone
()
if
stream_row
:
offset_stream_ordering
,
=
stream_row
...
...
@@ -662,6 +664,8 @@ class EventPushActionsStore(SQLBaseStore):
rotate_to_stream_ordering
=
self
.
stream_ordering_day_ago
caught_up
=
True
logger
.
info
(
"
Rotating notifications up to: %s
"
,
rotate_to_stream_ordering
)
self
.
_rotate_notifs_before_txn
(
txn
,
rotate_to_stream_ordering
)
# We have caught up iff we were limited by `stream_ordering_day_ago`
...
...
@@ -695,6 +699,8 @@ class EventPushActionsStore(SQLBaseStore):
txn
.
execute
(
sql
,
(
old_rotate_stream_ordering
,
rotate_to_stream_ordering
,))
rows
=
txn
.
fetchall
()
logger
.
info
(
"
Rotating notifications, handling %d rows
"
,
len
(
rows
))
# If the `old.user_id` above is NULL then we know there isn't already an
# entry in the table, so we simply insert it. Otherwise we update the
# existing table.
...
...
@@ -726,6 +732,8 @@ class EventPushActionsStore(SQLBaseStore):
(
old_rotate_stream_ordering
,
rotate_to_stream_ordering
,)
)
logger
.
info
(
"
Rotating notifications, deleted %s push actions
"
,
txn
.
rowcount
)
txn
.
execute
(
"
UPDATE event_push_summary_stream_ordering SET stream_ordering = ?
"
,
(
rotate_to_stream_ordering
,)
...
...
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