Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(send queue): generalize stored send queue data #4200

Merged
merged 5 commits into from
Nov 4, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Oct 31, 2024

See the first commit message, which explains the whole point.

Because of this PR, the send queue events and dependent events tables are both cleared, because there's a change in the format of serde-serialized data, and I didn't bother to write a migration for those. Events stuck in there would only be wedged events, or events that were still in the queue before closing the app; worst case scenario is some users lose some messages they tried to send before an update of an app. Is that OK? otherwise, can look into a sane migration, if needs be.

Part of #1732, blocks #4195.

…dent requests

This makes it possible to have different kinds of *parent key*, to
update a dependent request. A dependent request waits for the parent key
to be set, before it can be acted upon; before, it could only be an
event id, because a dependent request would only wait for an event to be
sent. In a soon future, we're going to support uploading medias as
requests, and some subsequent requests will depend on this, but won't be
able to rely on an event id (since an upload doesn't return an
event/event id).

Since this changes the format of `DependentQueuedRequest`, which is
directly serialized into the state stores, I've also cleared the table,
to not have to migrate the data in there. Dependent requests are
supposed to be transient anyways, so it would be a bug if they were many
of them in the queue.

Since a migration was needed anyways, I've also removed the `rename`
annotations (that supported a previous format) for the
`DependentQueuedRequestKind` enum.
…`, not a raw event

Changelog: The send queue will now store a serialized
 `QueuedRequestKind` instead of a raw event, which breaks the format.
 As a result, all send queues have been emptied.
@bnjbvr bnjbvr requested a review from a team as a code owner October 31, 2024 17:23
@bnjbvr bnjbvr requested review from poljar and removed request for a team October 31, 2024 17:24
@bnjbvr bnjbvr force-pushed the bnjbvr/refactor-send-queue-storage-for-realz branch from 9b197e2 to e9f90dc Compare October 31, 2024 17:28
@bnjbvr bnjbvr force-pushed the bnjbvr/refactor-send-queue-storage-for-realz branch from e9f90dc to e08d961 Compare October 31, 2024 17:30
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 84.87%. Comparing base (be88e0a) to head (12156c3).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/send_queue.rs 82.97% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4200      +/-   ##
==========================================
- Coverage   84.90%   84.87%   -0.03%     
==========================================
  Files         271      271              
  Lines       29070    29096      +26     
==========================================
+ Hits        24681    24695      +14     
- Misses       4389     4401      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

This looks good, but since you removed the migration test, do we have more migration tests that will run and check if everything is fine?

Also, do we want to double check on the app side that this indeed won't break in some unexpected way?

@@ -953,9 +957,17 @@ impl QueueStorage {
) -> Result<bool, RoomSendQueueError> {
let store = client.store();

let parent_key = de.parent_key;
Copy link
Contributor

Choose a reason for hiding this comment

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

de is a pretty bad name on its own, but it seems that it is doubly so because dependent events got renamed to dependent requests. So perhaps it's time to rename the variable here, please don't rename it to dqr.

@bnjbvr
Copy link
Member Author

bnjbvr commented Nov 4, 2024

Thanks for the review. As discussed in chat, I'll add back the migration test, and will make sure it checks that the content has now been cleared in the send queue, so we have some proof this is going to happen.

… and dependent events are cleared

Because the latest migration would clear events to-be-sent from the send
queue, we need to reflect this in this test.
@bnjbvr bnjbvr force-pushed the bnjbvr/refactor-send-queue-storage-for-realz branch from e08d961 to 03b1e32 Compare November 4, 2024 16:26
@bnjbvr bnjbvr enabled auto-merge (rebase) November 4, 2024 16:28
@bnjbvr bnjbvr merged commit 7a422fe into main Nov 4, 2024
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/refactor-send-queue-storage-for-realz branch November 4, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants