Skip to content

Commit

Permalink
Fix ConcurrentModificationException in RemoteFsTimestampAwareTranslog…
Browse files Browse the repository at this point in the history
….trimUnreferencedReaders

Signed-off-by: Sachin Kale <sachinpkale@gmail.com>
  • Loading branch information
sachinpkale committed Jan 15, 2025
1 parent fa4595c commit 044793f
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,17 @@ protected void trimUnreferencedReaders(boolean indexDeleted, boolean trimLocal)
}

// Update file tracker to reflect local translog state
Optional<Long> minLiveGeneration = readers.stream().map(BaseTranslogReader::getGeneration).min(Long::compareTo);
if (minLiveGeneration.isPresent()) {
List<String> staleFilesInTracker = new ArrayList<>();
for (String file : fileTransferTracker.allUploaded()) {
if (file.endsWith(TRANSLOG_FILE_SUFFIX)) {
long generation = Translog.parseIdFromFileName(file);
if (generation < minLiveGeneration.get()) {
staleFilesInTracker.add(file);
staleFilesInTracker.add(Translog.getCommitCheckpointFileName(generation));
}
long minLiveGeneration = getMinFileGeneration();
List<String> staleFilesInTracker = new ArrayList<>();
for (String file : fileTransferTracker.allUploaded()) {
if (file.endsWith(TRANSLOG_FILE_SUFFIX)) {
long generation = Translog.parseIdFromFileName(file);
if (generation < minLiveGeneration) {
staleFilesInTracker.add(file);
staleFilesInTracker.add(Translog.getCommitCheckpointFileName(generation));
}
fileTransferTracker.delete(staleFilesInTracker);
}
fileTransferTracker.delete(staleFilesInTracker);
}

// This is to ensure that after the permits are acquired during primary relocation, there are no further modification on remote
Expand Down

0 comments on commit 044793f

Please sign in to comment.