Skip to content

Avoid virtual thread pinning in procedure calling #34133

@AgilAghamirzayev

Description

@AgilAghamirzayev

Virtual thread pinning in procedure calling

Hi, I am using Java 21, spring boot 3.3.2

When I enable virtual 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");
			}
		}
	}

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions