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

Fix release race conditions and refactor core flows #192

Merged
merged 22 commits into from
May 25, 2023

Conversation

i-surkov
Copy link
Contributor

@i-surkov i-surkov commented May 19, 2023

Test specs added demonstrate race conditions when performing release of values under the same key, when there are multiple concurrent getOrUpdate1, put, and remove operations being performed. Two of these specs (put + remove, and getOrUpdate1 + put + remove) fail on the current master branch.

In short, there were several mix-ups as to which fiber should release which entry and in which case: some entries were being abandoned and not released after being removed, and for some, release was being performed more than once.

@i-surkov i-surkov requested a review from t3hnar May 19, 2023 16:47
@i-surkov i-surkov force-pushed the isurkov/fixed-release-race-conditions branch from 694dce9 to 643cfff Compare May 22, 2023 14:21
@i-surkov
Copy link
Contributor Author

Changed semantics as discussed with @t3hnar:

  1. getOrUpdate1 is responsible for releasing its values that it failed to place in the entryRef. Before, it would expect remove to wait for its deferred and release it. The new rule is more straightforward and allows for simpler reasoning regarding different states between getOrUpdate1, put and remove.
  2. remove only performs release of the loaded Values, and ignores Loading ones (returns None.pure[F]). Tests had to be adjusted.
  3. put doesn't retry anymore in case of CAS failure when putting new value in entryRef, and simply exit. That helps us to reduce contention, without sacrificing much of consistency.

@i-surkov i-surkov changed the title Fix release race conditions Fix release race conditions and refactor core flows May 25, 2023
@i-surkov i-surkov merged commit 6787cb1 into master May 25, 2023
4 of 7 checks passed
@i-surkov i-surkov deleted the isurkov/fixed-release-race-conditions branch May 25, 2023 11:50
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.

None yet

2 participants