mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-08 03:49:38 +00:00
Have circuit breaker succeed on unknown mem usage
With this commit we implement a workaround for https://bugs.openjdk.java.net/browse/JDK-8207200 which is a race condition in the JVM that results in `IllegalArgumentException` to be thrown in rare cases when we determine memory usage via `MemoryMXBean`. As we do not want to fail requests in those cases we always return zero memory usage. Relates #31767 Relates #33125
This commit is contained in:
parent
143cd9bbaa
commit
06c0055c0f
@ -251,7 +251,16 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService {
|
||||
|
||||
//package private to allow overriding it in tests
|
||||
long currentMemoryUsage() {
|
||||
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
|
||||
try {
|
||||
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// This exception can happen (rarely) due to a race condition in the JVM when determining usage of memory pools. We do not want
|
||||
// to fail requests because of this and thus return zero memory usage in this case. While we could also return the most
|
||||
// recently determined memory usage, we would overestimate memory usage immediately after a garbage collection event.
|
||||
assert ex.getMessage().matches("committed = \\d+ should be < max = \\d+");
|
||||
logger.info("Cannot determine current memory usage due to JDK-8207200.", ex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user