This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 7d587ec03 RATIS-2017: checkAndEvictCache must be done in writeLock.
(#1031)
7d587ec03 is described below
commit 7d587ec03c3d6e592a1fd544d93094fdeb229c45
Author: Duong Nguyen <[email protected]>
AuthorDate: Sat Jan 27 13:10:03 2024 -0800
RATIS-2017: checkAndEvictCache must be done in writeLock. (#1031)
---
.../ratis/server/raftlog/segmented/SegmentedRaftLog.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
index 92b2d4233..4e057c07b 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
@@ -326,11 +326,13 @@ public final class SegmentedRaftLog extends RaftLogBase {
private void checkAndEvictCache() {
if (cache.shouldEvict()) {
- // TODO if the cache is hitting the maximum size and we cannot evict any
- // segment's cache, should block the new entry appending or new segment
- // allocation.
- cache.evictCache(server.getFollowerNextIndices(),
fileLogWorker.getSafeCacheEvictIndex(),
- server.getLastAppliedIndex());
+ try (AutoCloseableLock ignored = writeLock()){
+ // TODO if the cache is hitting the maximum size and we cannot evict
any
+ // segment's cache, should block the new entry appending or new segment
+ // allocation.
+ cache.evictCache(server.getFollowerNextIndices(),
fileLogWorker.getSafeCacheEvictIndex(),
+ server.getLastAppliedIndex());
+ }
}
}