Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use receipts event_stream_ordering column, remove joins to events #13918

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Fizzadar
Copy link
Contributor

@Fizzadar Fizzadar commented Sep 27, 2022

Follow up to: cdbb641

This relies on the completion of the background task introduced by the above change. I suggest that we leave this in draft for N(?) releases and then force the migration similar to da41a7c#diff-ddb3c5844daede09acca491cc04a3740730179fca1fa75aa25b921727209947a, probably with an appropriate upgrade note at the time.

Signed off by Nick @ Beeper (@Fizzadar).

Pull Request Checklist

@Fizzadar Fizzadar force-pushed the use-receipts-stream-ordering branch 2 times, most recently from fe25007 to 95e77d7 Compare September 27, 2022 14:28
@Fizzadar
Copy link
Contributor Author

Fizzadar commented Oct 3, 2022

Worth noting that we are running this in our synapse install and it has yielded a significant reduction to databse IOPs when generating push actions in large rooms.

@clokep
Copy link
Member

clokep commented Dec 5, 2022

@Fizzadar is this worth revisiting now that it has been several releases?

@Fizzadar
Copy link
Contributor Author

@clokep yes, is on my list! However it's actually a bit blocked currently by receipts for unknown event IDs which I'm just starting to investigate on our end (starting point: beeper/synapse@21964cf).

@Fizzadar Fizzadar force-pushed the use-receipts-stream-ordering branch 3 times, most recently from 1379742 to 5e0c976 Compare February 4, 2023 13:44
This removes a bunch of joins against the events table.
This should be impossible, check is here to pevent bad actors from breaking
synapse with receipts for non-events.
@Fizzadar Fizzadar force-pushed the use-receipts-stream-ordering branch from 5e0c976 to 5eb0ef2 Compare February 4, 2023 15:46
@Fizzadar Fizzadar marked this pull request as ready for review February 4, 2023 17:06
@Fizzadar Fizzadar requested a review from a team as a code owner February 4, 2023 17:06
Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable!

If, for whatever reason, the background update to populate event_stream_ordering has not finished, what's the worst that could happen?

Comment on lines 598 to +606
# Now, pretend that we receive a large burst of read receipts (300 total) that
# all come in at once.
for i in range(300):
for _ in range(300):
room_id = self.helper.create_room_as(
self.local_user, tok=self.local_user_token
)
resp = self.helper.send(room_id, tok=self.local_user_token)
event_id = resp["event_id"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a room in between each read receipt does a lot of stuff, including creating new events. I'm not sure if this test is still testing the intended scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this is also very slow, not sure how to proceed here. The original test specifies a unique room/event per receipt so I was trying to replicate that...

@squahtx squahtx added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Feb 7, 2023
@Fizzadar
Copy link
Contributor Author

If, for whatever reason, the background update to populate event_stream_ordering has not finished, what's the worst that could happen?

I think this may cause issues with rotation of event push actions -> event push summaries. Wouldn't break anything user-facing but would impact the database. I think best bet here is to force through the migration as was done here. Will address this first and re-request review then.

@clokep
Copy link
Member

clokep commented Aug 24, 2023

@Fizzadar Any interest in continuing this? I think the unknown events for receipts bit was fixed now too?

@Fizzadar
Copy link
Contributor Author

@clokep yes and yes I believe so! Hoping to loop back on this later this week time permitting!

# Conflicts:
#	tests/rest/client/test_receipts.py
@Fizzadar
Copy link
Contributor Author

Fizzadar commented Nov 5, 2023

I've merged in the latest develop. I don't think the migration needs to be forced because push summary rotation iterates over receipts using stream ID, and sufficient time has passed since the column was populated which will mean anything being rotated now will have the value. The DB compat version (72 at original PR time) is now 80 so there's no concerns with downgrades.

So I think the only outstanding thing here is the heavy test code, I'll see what I can do there and re-request review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants