Skip to content

Commit

Permalink
Use readlock for reading epochs in LeaderEpochFIleCache (apache#13483)
Browse files Browse the repository at this point in the history
Reviewers: Divij Vaidya <[email protected]>, Satish Duggana <[email protected]>
  • Loading branch information
showuon authored Mar 31, 2023
1 parent 8c88cdb commit d849d66
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ private boolean assign(EpochEntry entry) {
private void maybeTruncateNonMonotonicEntries(EpochEntry newEntry) {
List<EpochEntry> removedEpochs = removeFromEnd(entry -> entry.epoch >= newEntry.epoch || entry.startOffset >= newEntry.startOffset);


if (removedEpochs.size() > 1 || (!removedEpochs.isEmpty() && removedEpochs.get(0).startOffset != newEntry.startOffset)) {

// Only log a warning if there were non-trivial removals. If the start offset of the new entry
Expand Down Expand Up @@ -383,11 +382,11 @@ public void clear() {

// Visible for testing
public List<EpochEntry> epochEntries() {
lock.writeLock().lock();
lock.readLock().lock();
try {
return new ArrayList<>(epochs.values());
} finally {
lock.writeLock().unlock();
lock.readLock().unlock();
}
}

Expand Down

0 comments on commit d849d66

Please sign in to comment.