Skip to content

Avoid virtual thread pinning in procedure callingΒ #34133

Closed

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");
			}
		}
	}

Activity

  1. added
    in: dataIssues in data modules (jdbc, orm, oxm, tx)
    and removed on Dec 21, 2024
  2. self-assigned this
    on Dec 21, 2024
  3. added this to the 6.2.2 milestone on Dec 21, 2024
  4. changed the title [-]Virtual thread pinning in procedure calling[/-] [+]Avoid virtual thread pinning in procedure calling[/+] on Dec 21, 2024
  5. lucky8987 commented on Dec 26, 2024

    @lucky8987
    Contributor

    @jhoeller Can I optimize this problem? I will use CAS lock free processing for this scenario.

  6. added a commit that references this issue on Jan 12, 2025
    2528720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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