Description
After upgrading openj9 from 21.0.3 to 21.0.7, the application will inexplicably experience OOM.
During concurrent thread operations, the size of Concurrent HashMap suddenly increases from 1 to the maximum value for shaping. The code Sets.newConcurrentHashSet() is an implementation of guava, and the underlying layer uses Concurrent HashMap
The HashMap used at the bottom layer of Sets.newHashSet (allocStacks) is OOM because the size reaches the maximum shaping value, resulting in the size of newHashSet also being the maximum shaping value.
why the size of Concurrent HashMap suddenly increases from 1 to its maximum value during concurrent thread operations
This only occurs when using shared class cache, and if the shared class cache is removed, it will not occur.
ConnectionAllocMonitor:
private Set<ConnectionAllocStack> allocStacks = Sets.newConcurrentHashSet();
private long lastOutTime = 0;
public void addConnectionAllocStack(ConnectionAllocStack allocStack){
allocStacks.add(allocStack);
logger.info("====" + this + ": " + allocStacks.size());
if(allocStacks.size()>=poolMaxSize&){
Set<ConnectionAllocStack> tempallocStacks = Sets.newHashSet(allocStacks);
logger.info(">>>>>>>>> connection pool is full ,output statck info:");
tempallocStacks.stream().forEach(stack->{
});
logger.info(">>>>>>>>> end connection output statck");
lastOutTime= System.currentTimeMillis();
}
}
log:
2025-05-30 09:56:14 453 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][Thread-9] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@234b0671: 1
2025-05-30 09:56:14 462 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][Thread-9
5A9D
] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@556d58e7: 1
2025-05-30 09:56:14 652 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][Thread-9] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@556d58e7: 1
2025-05-30 09:56:21 946 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][app-executor-lv:1-idx:1] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@556d58e7: 2147483647
2025-05-30 09:56:21 946 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][app-executor-lv:1-idx:3] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@556d58e7: 2147483647
2025-05-30 09:56:21 947 INFO [com.tmp.db.jdbi.ConnectionAllocMonitor][app-executor-lv:1-idx:6] - ====com.tmp.db.jdbi.ConnectionAllocMonitor@556d58e7: 2147483647