This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new dfd7a7b7d8 Add debug logging for cache size
dfd7a7b7d8 is described below
commit dfd7a7b7d8a18ef6ea05bef0a5645c0f845339ba
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 30 10:50:40 2024 +0000
Add debug logging for cache size
---
java/org/apache/catalina/webresources/Cache.java | 18 +++++++++++++++---
.../catalina/webresources/LocalStrings.properties | 2 ++
webapps/docs/changelog.xml | 9 +++++++--
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/webresources/Cache.java
b/java/org/apache/catalina/webresources/Cache.java
index 03e933d37c..ad41aaa983 100644
--- a/java/org/apache/catalina/webresources/Cache.java
+++ b/java/org/apache/catalina/webresources/Cache.java
@@ -99,7 +99,11 @@ public class Cache {
// there is still benefit in caching the resource metadata
long delta = cacheEntry.getSize();
- size.addAndGet(delta);
+ long result = size.addAndGet(delta);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cache.sizeTracking.add",
Long.toString(delta), cacheEntry, path,
+ Long.toString(result)));
+ }
if (size.get() > maxSize) {
// Process resources unordered for speed. Trades cache
@@ -175,7 +179,11 @@ public class Cache {
// Content will not be cached but we still need metadata size
long delta = cacheEntry.getSize();
- size.addAndGet(delta);
+ long result = size.addAndGet(delta);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cache.sizeTracking.add",
Long.toString(delta), cacheEntry, path,
+ Long.toString(result)));
+ }
if (size.get() > maxSize) {
// Process resources unordered for speed. Trades cache
@@ -261,7 +269,11 @@ public class Cache {
CachedResource cachedResource = resourceCache.remove(path);
if (cachedResource != null) {
long delta = cachedResource.getSize();
- size.addAndGet(-delta);
+ long result = size.addAndGet(-delta);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cache.sizeTracking.remove",
Long.toString(delta), cachedResource, path,
+ Long.toString(result)));
+ }
}
}
diff --git a/java/org/apache/catalina/webresources/LocalStrings.properties
b/java/org/apache/catalina/webresources/LocalStrings.properties
index 0b8472f238..c964d31291 100644
--- a/java/org/apache/catalina/webresources/LocalStrings.properties
+++ b/java/org/apache/catalina/webresources/LocalStrings.properties
@@ -26,6 +26,8 @@ cache.addFail=Unable to add the resource at [{0}] to the
cache for web applicati
cache.backgroundEvictFail=The background cache eviction process was unable to
free [{0}] percent of the cache for Context [{1}] - consider increasing the
maximum size of the cache. After eviction approximately [{2}] KiB of data
remained in the cache.
cache.objectMaxSizeTooBig=The value of [{0}] KiB for objectMaxSize is larger
than the limit of maxSize/20 so has been reduced to [{1}] KiB
cache.objectMaxSizeTooBigBytes=The value specified for the maximum object size
to cache [{0}] KiB is greater than Integer.MAX_VALUE bytes which is the maximum
size that can be cached. The limit will be set to Integer.MAX_VALUE bytes.
+cache.sizeTracking.add=Increased cache size by [{0}] for item [{1}] at [{2}]
making total cache size [{3}]
+cache.sizeTracking.removed=Decreased cache size by [{0}] for item [{1}] at
[{2}] making total cache size [{3}]
cachedResource.invalidURL=Unable to create an instance of
CachedResourceURLStreamHandler because the URL [{0}] is malformed
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 89815fcce8..c7b7d04603 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -203,9 +203,14 @@
(remm)
</fix>
<fix>
- Fix incorrect cache size calculations when there is a concurrent PUT
and
- DELETE for the same resource. (markt)
+ Fix incorrect web resource cache size calculations when there are
+ concurrent <code>PUT</code> and <code>DELETE</code> requests for the
+ same resource. (markt)
</fix>
+ <add>
+ Add debug logging for the web resource cache so the current size can be
+ tracked as resources are added and removed. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]