mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-10 15:00:11 -04:00
Speed up get_unread_event_push_actions_by_room
(#13005)
Fixes #11887 hopefully. The core change here is that `event_push_summary` now holds a summary of counts up until a much more recent point, meaning that the range of rows we need to count in `event_push_actions` is much smaller. This needs two major changes: 1. When we get a receipt we need to recalculate `event_push_summary` rather than just delete it 2. The logic for deleting `event_push_actions` is now divorced from calculating `event_push_summary`. In future it would be good to calculate `event_push_summary` while we persist a new event (it should just be a case of adding one to the relevant rows in `event_push_summary`), as that will further simplify the get counts logic and remove the need for us to periodically update `event_push_summary` in a background job.
This commit is contained in:
parent
9ad2197fa7
commit
0d1d3e0708
14 changed files with 322 additions and 151 deletions
|
@ -51,10 +51,16 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
|
|||
room_id = "!foo:example.com"
|
||||
user_id = "@user1235:example.com"
|
||||
|
||||
last_read_stream_ordering = [0]
|
||||
|
||||
def _assert_counts(noitf_count, highlight_count):
|
||||
counts = self.get_success(
|
||||
self.store.db_pool.runInteraction(
|
||||
"", self.store._get_unread_counts_by_pos_txn, room_id, user_id, 0
|
||||
"",
|
||||
self.store._get_unread_counts_by_pos_txn,
|
||||
room_id,
|
||||
user_id,
|
||||
last_read_stream_ordering[0],
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
|
@ -98,6 +104,7 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
|
|||
)
|
||||
|
||||
def _mark_read(stream, depth):
|
||||
last_read_stream_ordering[0] = stream
|
||||
self.get_success(
|
||||
self.store.db_pool.runInteraction(
|
||||
"",
|
||||
|
@ -144,8 +151,19 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
|
|||
_assert_counts(1, 1)
|
||||
_rotate(9)
|
||||
_assert_counts(1, 1)
|
||||
_rotate(10)
|
||||
_assert_counts(1, 1)
|
||||
|
||||
# Check that adding another notification and rotating after highlight
|
||||
# works.
|
||||
_inject_actions(10, PlAIN_NOTIF)
|
||||
_rotate(11)
|
||||
_assert_counts(2, 1)
|
||||
|
||||
# Check that sending read receipts at different points results in the
|
||||
# right counts.
|
||||
_mark_read(8, 8)
|
||||
_assert_counts(1, 0)
|
||||
_mark_read(10, 10)
|
||||
_assert_counts(0, 0)
|
||||
|
||||
def test_find_first_stream_ordering_after_ts(self):
|
||||
def add_event(so, ts):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue