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

pagination: don't hold onto the waited_for_initial_prev_token lock for long #3501

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jun 4, 2024

While this mutex is taken, in oldest_token() we can get a hold of the RoomEvent mutex, making it so that the waited_... token covers the critical region of room events.

Unfortunately, in clear(), we're taking these two locks in the opposite order, implying that the room events critical region now overlaps that of the waited_... lock.

The way to break the cycle is to keep the waited_ token for as short as possible.

…r too long

While this mutex is taken, in `oldest_token()` we can get a hold of the
RoomEvent mutex, making it so that the `waited_...` token covers the
critical region of room events.

Unfortunately, in `clear()`, we're taking these two locks in the
opposite order, implying that the room events critical region now
overlaps that of the `waited_...` lock.

The way to break the cycle is to keep the `waited_` token for as short
as possible.
@bnjbvr bnjbvr requested a review from a team as a code owner June 4, 2024 09:06
@bnjbvr bnjbvr requested review from poljar and removed request for a team June 4, 2024 09:06
@ganfra
Copy link
Contributor

ganfra commented Jun 4, 2024

Tested ok on EXA!

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.73%. Comparing base (78608a1) to head (f6a100b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3501   +/-   ##
=======================================
  Coverage   83.73%   83.73%           
=======================================
  Files         255      255           
  Lines       25778    25778           
=======================================
  Hits        21584    21584           
  Misses       4194     4194           

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

@bnjbvr bnjbvr changed the title pagination: don't hold onto the waited_for_initial_prev_token lock for long pagination: don't hold onto the waited_for_initial_prev_token lock for long Jun 4, 2024
Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@bnjbvr bnjbvr merged commit 77f0b6a into main Jun 4, 2024
38 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/fix-race-get-or-wait-for-token branch June 4, 2024 09:46
@Hywan
Copy link
Member

Hywan commented Jun 4, 2024

Well done! 👏

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.

4 participants