hibernate/hibernate-orm · error · HibernateException

Exception pulsing TransactionCoordinator

Error message

Exception pulsing TransactionCoordinator

What it means

Before executing JDBC work, SharedSessionContract pulses the TransactionCoordinator to resume/join the transaction for the current thread. Any non-Hibernate RuntimeException from that pulse (driver, connection pool, JTA resume failure) is wrapped in HibernateException('Exception pulsing TransactionCoordinator') with the real cause attached. It marks infrastructure failure during transaction re-association, not an API misuse.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java:1403

		}
		return transaction;
	}

	protected void checkTransactionSyncStatus() {
		pulseTransactionCoordinator();
		delayedAfterCompletion();
	}

	protected void pulseTransactionCoordinator() {
		if ( !isClosed() ) {
			try {
				transactionCoordinator.pulse();
			}
			catch (HibernateException e) {
				throw e;
			}
			catch (RuntimeException e) {
				throw new HibernateException( "Exception pulsing TransactionCoordinator", e );
			}
		}
	}

	@Override
	public void joinTransaction() {
		checkOpen();
		try {
			// For a non-JTA TransactionCoordinator, this just logs a WARNing
			transactionCoordinator.explicitJoin();
		}
		catch ( TransactionRequiredForJoinException e ) {
			throw new TransactionRequiredException( e.getMessage() );
		}
		catch ( HibernateException he ) {
			throw getExceptionConverter().convert( he );
		}
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Inspect HibernateException.getCause() — the SQLException/XAException/Narayana exception identifies the real failure and dictates the fix.
  2. Stale connections: set pool maxLifetime below the database idle timeout and enable checkout validation (connection test query or isValid).
  3. JTA resume failures: check XA recovery logs and transaction timeouts; start a fresh transaction rather than reusing the session.
  4. Retry the unit of work in a new session/transaction once the resource is healthy; do not retry on the same broken session.

Example fix

// before: pooled connection invalidated by db idle timeout, next query throws
session.createQuery(...).list();
// after: bounded maxLifetime + validation, and failover to a fresh session
// hikari: maximumPoolLifetime < db wait_timeout, connectionTestQuery or isValid on checkout
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return session.createQuery(...).list();
} catch (HibernateException e) {
    if ("Exception pulsing TransactionCoordinator".equals(e.getMessage())) {
        Throwable root = rootCause(e); // inspect SQLException / XAException
        if (isTransientConnectionFailure(root)) {
            try (Session fresh = sessionFactory.openSession()) {
                fresh.beginTransaction();
                return fresh.createQuery(...).list(); // one retry on a healthy session
            }
        }
    }
    throw e;
}

Prevention

When it happens

Trigger: The underlying connection was killed or invalidated by the pool (eager eviction, database wait_timeout) before the pulse; XA transaction resume/re-register fails (Narayana recovery issues, tx timeouts); driver throws while beforeQuery/afterTransaction hooks re-attach resources.

Common situations: MySQL wait_timeout closing pooled connections and the next query pulsing a dead coordinator; HikariCP/Agroal eviction racing an in-flight session; WildFly/Narayana XA recovery problems after a crash; app/container resumed from suspend with stale connections.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/ca13165f13a20478. Report an issue: GitHub.