Virtual thread pinning in procedure calling
Hi, I am using Java 21, spring boot 3.3.2
When I enablevirtual threads
and -Djdk.tracePinnedThreads=short
I got virtual thread pinning and deadlock my requests.
The pinning log :
Thread[#179,ForkJoinPool-1-worker-28,5,CarrierThreads] org.springframework.jdbc.core.simple.AbstractJdbcCall.compile(AbstractJdbcCall.java:298) <== monitors:1
I review the code there used synchronized in method level. Could we change it to java locking library.
public final synchronized void compile() throws InvalidDataAccessApiUsageException {
if (!isCompiled()) {
if (getProcedureName() == null) {
throw new InvalidDataAccessApiUsageException("Procedure or Function name is required");
}
try {
this.jdbcTemplate.afterPropertiesSet();
}
catch (IllegalArgumentException ex) {
throw new InvalidDataAccessApiUsageException(ex.getMessage());
}
compileInternal();
this.compiled = true;
if (logger.isDebugEnabled()) {
logger.debug("SqlCall for " + (isFunction() ? "function" : "procedure") +
" [" + getProcedureName() + "] compiled");
}
}
}
Comment From: lucky8987
@jhoeller Can I optimize this problem? I will use CAS lock free processing for this scenario.