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

[MM-54328] Fix call state race condition #512

Merged
merged 4 commits into from
Sep 7, 2023
Merged

[MM-54328] Fix call state race condition #512

merged 4 commits into from
Sep 7, 2023

Conversation

streamer45
Copy link
Collaborator

Summary

PR fixes a race condition that could cause the call state to be incorrectly updated with stale data. Contrary to what I originally thought, this didn't happen on join. In fact, we don't fetch the call state when joining but when switching channel. So if switching to the channel the call was ongoing while some other users were joining, it could happen (actually quite easy to reproduce) that the final state missed some profiles.

The solution here is to send the whole call state through the websocket channel upon joining the call. This ensures the call is up to date as other events are guaranteed to be received in order.

To be noted, this PR only fixes the above case of joining a call. There are still a few possible races when loading Mattermost the first time. Unfortunately this includes opening the popout window although I couldn't easily reproduce this case so far. To fix that we likely need something a bit more involved because it's not straightforward to guarantee sequencing of events there. Need to think it a bit more.

Ticket Link

https://mattermost.atlassian.net/browse/MM-54328

@streamer45 streamer45 added the 2: Dev Review Requires review by a core committer label Aug 31, 2023
@streamer45 streamer45 requested a review from cpoile August 31, 2023 18:53
@streamer45 streamer45 self-assigned this Aug 31, 2023
Comment on lines -838 to -837
fetchChannelData(currChannelId).then((actions) =>
store.dispatch(batchActions(actions)),
);
Copy link
Collaborator Author

@streamer45 streamer45 Aug 31, 2023

Choose a reason for hiding this comment

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

I am removing this as I don't think it's needed anymore. We fetch all channels/calls anyway on first load and then rely on websocket to keep things up to date. I couldn't see any side effect so far but will need to monitor.

@codecov-commenter
Copy link

codecov-commenter commented Aug 31, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02% ⚠️

Comparison is base (7b200f3) 5.43% compared to head (e3c85fa) 5.42%.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #512      +/-   ##
========================================
- Coverage   5.43%   5.42%   -0.02%     
========================================
  Files         24      24              
  Lines       4378    4387       +9     
========================================
  Hits         238     238              
- Misses      4123    4132       +9     
  Partials      17      17              
Files Changed Coverage Δ
server/websocket.go 0.00% <0.00%> (ø)

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

Copy link
Member

@cpoile cpoile 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 like it will simplify things, thank you!

server/websocket.go Show resolved Hide resolved
server/websocket.go Show resolved Hide resolved
standalone/src/recording/index.tsx Show resolved Hide resolved
webapp/src/actions.ts Outdated Show resolved Hide resolved
@streamer45 streamer45 added 3: Reviews Complete All reviewers have approved the pull request Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) and removed 2: Dev Review Requires review by a core committer labels Sep 1, 2023
@streamer45 streamer45 added this to the v0.19.0 - MM 9.0 milestone Sep 6, 2023
Base automatically changed from MM-53081 to main September 7, 2023 00:36
@streamer45 streamer45 removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Sep 7, 2023
@streamer45 streamer45 merged commit d693d45 into main Sep 7, 2023
4 checks passed
@streamer45 streamer45 deleted the MM-54328 branch September 7, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants