This is an automated email from the ASF dual-hosted git repository.
satishd pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new d849d667171 Use readlock for reading epochs in LeaderEpochFIleCache
(#13483)
d849d667171 is described below
commit d849d667171103d2403c4da0cb3852c11b8aa4b8
Author: Luke Chen <[email protected]>
AuthorDate: Fri Mar 31 20:33:29 2023 +0800
Use readlock for reading epochs in LeaderEpochFIleCache (#13483)
Reviewers: Divij Vaidya <[email protected]>, Satish Duggana
<[email protected]>
---
.../apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git
a/storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java
b/storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java
index 95c6973fa95..7ba3e388fe2 100644
---
a/storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java
+++
b/storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java
@@ -114,7 +114,6 @@ public class LeaderEpochFileCache {
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
@@ -383,11 +382,11 @@ public class LeaderEpochFileCache {
// 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();
}
}