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 <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]