You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/03/10 09:15:17 UTC
(tomcat) branch main updated: Handle eviction running over a bucket boundary.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new f8e0c4ef07 Handle eviction running over a bucket boundary.
f8e0c4ef07 is described below
commit f8e0c4ef071d119b7812995d01edc0a8517aaa34
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 10 09:14:54 2025 +0000
Handle eviction running over a bucket boundary.
Patch by Chenjp
---
java/org/apache/catalina/util/TimeBucketCounterBase.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/util/TimeBucketCounterBase.java b/java/org/apache/catalina/util/TimeBucketCounterBase.java
index 4679a41f0a..122a7b02fa 100644
--- a/java/org/apache/catalina/util/TimeBucketCounterBase.java
+++ b/java/org/apache/catalina/util/TimeBucketCounterBase.java
@@ -181,10 +181,17 @@ public abstract class TimeBucketCounterBase {
* long run.
*/
public void periodicEvict() {
- String currentBucketPrefix = String.valueOf(getCurrentBucketPrefix());
+ /*
+ * The implementation of this method assumes that the time taken for eviction is less than 1 bucket duration.
+ * It is possible that the eviction process starts in one bucket but finishes in another. Therefore, keys for
+ * the current bucket and the next bucket when the eviction process starts are excluded from eviction.
+ */
+ long currentBucketIndex = getCurrentBucketPrefix();
+ String currentBucketPrefix = String.valueOf(currentBucketIndex);
+ String nextBucketPrefix = String.valueOf(currentBucketIndex + 1);
ConcurrentHashMap.KeySetView<String,AtomicInteger> keys = map.keySet();
// remove obsolete keys
- keys.removeIf(k -> !k.startsWith(currentBucketPrefix));
+ keys.removeIf(k -> !k.startsWith(currentBucketPrefix) && !k.startsWith(nextBucketPrefix));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org