-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 ConcurrentModificationException in RemoteFsTimestampAwareTranslog.trimUnreferencedReaders #17028
base: main
Are you sure you want to change the base?
Fix ConcurrentModificationException in RemoteFsTimestampAwareTranslog.trimUnreferencedReaders #17028
Conversation
❌ Gradle check result for bbb355d: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
….trimUnreferencedReaders Signed-off-by: Sachin Kale <sachinpkale@gmail.com>
bbb355d
to
044793f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17028 +/- ##
============================================
+ Coverage 72.11% 72.25% +0.14%
- Complexity 65260 65326 +66
============================================
Files 5301 5301
Lines 303801 303803 +2
Branches 44029 44028 -1
============================================
+ Hits 219098 219528 +430
+ Misses 66686 66280 -406
+ Partials 18017 17995 -22 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
} | ||
fileTransferTracker.delete(staleFilesInTracker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me @sachinpkale . Just one question regarding this delete function call.
We are calling fileTransferTracker.delete(staleFilesInTracker);
inside this for loop. In case of multiple generation uploaded won't we be calling delete for already deleted files? Just thinking if we can move out this delete function call out of this for loop.
Description
RemoteFsTimestampAwareTranslog.trimUnreferencedReaders
, in order to update file tracker to reflect local translog state, we fetch the minimum generation across all readers and delete all generations fromFileTransferTracker
that are less than the min generation.OpenSearch/server/src/main/java/org/opensearch/index/translog/RemoteFsTimestampAwareTranslog.java
Lines 128 to 141 in 34ef146
readers
is ArrayList, that means without locking readers if we try to read the list contents, we will getConcurrentModificationException
if a other thread is writing to readers.Translog
class that safely returns the min generation by taking a read lock:getMinFileGeneration()
getMinFileGeneration()
to get the min generation.Related Issues
Check List
[ ] Functionality includes testing.[ ] API changes companion pull request created, if applicable.[ ] Public documentation issue/PR created, if applicable.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.