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): use a specialized mutex for locking access to the state store and being_sent #4268

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Nov 14, 2024

There was an implicit relationship that the being_sent lock needed to be taken in order to do non-atomic state store operations. With the change from this commit, the relationship is now more explicit: to get a handle to the state store, or being_sent, you have to obtain a StoreLockGuard by locking against the store itself. The WeakClient isn't stored in the QueueStorage data structure itself, so it's the only way to get a dyn StateStore from the QueueStorage.

@bnjbvr bnjbvr requested a review from a team as a code owner November 14, 2024 16:05
@bnjbvr bnjbvr requested review from Hywan and removed request for a team November 14, 2024 16:05
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.02%. Comparing base (a8a83c3) to head (01ed8ad).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4268      +/-   ##
==========================================
- Coverage   85.03%   85.02%   -0.01%     
==========================================
  Files         274      274              
  Lines       30028    30039      +11     
==========================================
+ Hits        25533    25541       +8     
- Misses       4495     4498       +3     

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

…he state store and `being_sent`

There was an implicit relationship that the `being_sent` lock needed to
be taken in order to do non-atomic state store operations. With the
change from this commit, the relationship is now more explicit: to get a
handle to the state store, or being_sent, you have to obtain a
`StoreLockGuard` by locking against the store itself. The `WeakClient`
isn't stored in the QueueStorage data structure itself, so it's the only
way to get a `dyn StateStore` from the `QueueStorage`.
@bnjbvr bnjbvr force-pushed the bnjbvr/being-sent-plus-store2 branch from 473d03d to 01ed8ad Compare November 18, 2024 13:40
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -1136,12 +1179,8 @@ impl QueueStorage {
file_media_request: MediaRequestParameters,
thumbnail: Option<(FinishUploadThumbnailInfo, MediaRequestParameters, Mime)>,
) -> Result<(), RoomSendQueueStorageError> {
// Keep the lock until we're done touching the storage.
// TODO refactor to make the relationship between being_sent and the store more
Copy link
Member

Choose a reason for hiding this comment

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

👍

@bnjbvr bnjbvr enabled auto-merge (rebase) November 18, 2024 13:45
@bnjbvr bnjbvr merged commit f1a442b into main Nov 18, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/being-sent-plus-store2 branch November 18, 2024 13:55
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