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 the potential access to upsert metadata manager after it is closed #11692

Merged

Conversation

Jackie-Jiang
Copy link
Contributor

@Jackie-Jiang Jackie-Jiang commented Sep 27, 2023

Fix the race condition which can cause access to the upsert metadata after the manager is closed:

  • Thread 1 finishes the _stopped flag check but not invoking startOperation() yet (it might block on snapshot lock)
  • Thread 2 stops and closes the metadata manager
  • Thread 1 calls startOperation() and start accessing the metadata

In this PR, make startOperation() return false if the pending operations (reference count) already drops to 0, and also merge stopped flag check into startOperation() to simplify the logic. This is not super performance sensitive, so using very tight synchronized block should be fine

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2023

Codecov Report

Merging #11692 (80fb565) into master (1748be4) will increase coverage by 0.02%.
Report is 5 commits behind head on master.
The diff coverage is 42.55%.

@@             Coverage Diff              @@
##             master   #11692      +/-   ##
============================================
+ Coverage     63.02%   63.04%   +0.02%     
  Complexity     1120     1120              
============================================
  Files          2343     2343              
  Lines        125672   125672              
  Branches      19314    19317       +3     
============================================
+ Hits          79209    79236      +27     
+ Misses        40808    40782      -26     
+ Partials       5655     5654       -1     
Flag Coverage Δ
integration <0.01% <0.00%> (ø)
integration1 <0.01% <0.00%> (ø)
integration2 0.00% <0.00%> (ø)
java-11 63.03% <42.55%> (+12.97%) ⬆️
java-17 62.90% <42.55%> (+48.45%) ⬆️
java-20 14.43% <0.00%> (-48.46%) ⬇️
temurin 63.04% <42.55%> (+0.02%) ⬆️
unittests 63.04% <42.55%> (+0.02%) ⬆️
unittests1 67.19% <42.55%> (+<0.01%) ⬆️
unittests2 14.45% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...cal/upsert/BasePartitionUpsertMetadataManager.java 40.61% <42.55%> (+1.00%) ⬆️

... and 14 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Jackie-Jiang Jackie-Jiang merged commit 82de30d into apache:master Sep 27, 2023
19 checks passed
@Jackie-Jiang Jackie-Jiang deleted the upsert_metadata_manager_robust branch September 27, 2023 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants