pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: papegaaij (@papegaaij) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3724: Regression: FATAL:  simple query "BEGIN" arrived before ending an extended query message
Date: Wed, 09 Jul 2025 07:46:00 +0000
Message-ID: <[email protected]> (raw)

Since the upgrade to 42.7.7 we are experiencing intermittent errors on our database connections. The error reads `FATAL: simple query "BEGIN" arrived before ending an extended query message`. This errors is emitted by pgpool-II, so it could also be a bug in pgpool-II triggered by this new version of PgJDBC. However, the error gives me the impression that a previous query is not closed properly, which seems to point to PgJDBC. Unfortunately, we don't have a path to reproduction. We've observed the error about 10 times every hour, and it stopped the moment we downgraded PgJDBC to 42.7.5, so we are very sure the trigger is in PgJDBC.

**Environment**
PgJDBC 42.7.7 (broken) 42.7.5 (ok)
PostgreSQL 17.5 on Alpine 3.21.3 in docker
pgpool-II 4.6.2
OpenJDK Runtime Environment Temurin-21.0.7+6
WildFly 36.0.1

**Stacktrace**
```
2025-07-08T06:41:22+02:00 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (backend task-145) SQL Error: 0, SQLState: XX000
2025-07-08T06:41:22+02:00 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (backend task-145) FATAL: simple query "BEGIN" arrived before ending an extended query message
2025-07-08T06:41:22+02:00 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (backend task-145) SQL Error: 0, SQLState: 08006
2025-07-08T06:41:22+02:00 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (backend task-145) An I/O error occurred while sending to the backend.
2025-07-08T06:41:22+02:00 ERROR [org.jboss.as.ejb3.invocation] (backend task-145) WFLYEJB0034: Jakarta Enterprise Beans Invocation failed on component VaultRecordDAO for method public java.util.List nl.topicus.cobra.dao.data.AbstractDAO.get(int,int,nl.topicus.cobra.dao.filter.AbstractZoekFilter): jakarta.ejb.EJBTransactionRolledbackException: JDBC exception executing SQL [select pr1_0.id,pr1_0.color,pr1_0.createdAt,pr1_0.createdBy,pr1_0.derived,pr1_0.endDate,pr1_0.filename,pr1_0.lastModifiedAt,pr1_0.lastmodifiedby,pr1_0.metadata,pr1_0.name,pr1_0.parent,pr1_0.recordKey,pr1_0.shareEndTime,pr1_0.url,pr1_0.username,pr1_0.uuid,pr1_0.vault,pr1_0.version,pr1_0.warningPeriod from VAULT_RECORD pr1_0 where (pr1_0.vault in ((select p2_0.vault from KHGROUP p2_0 where (p2_0.organizationalunit=?) and (p2_0.id=?) and p2_0.id=?)) or pr1_0.vault in ((select vs1_0.vault from CLIENT_APPLICATION pc1_0 join KHGROUP o1_0 on o1_0.id=pc1_0.owner join VAULT_SECRETS vs1_0 on vs1_0.id=pc1_0.vaultsecrets where (o1_0.organizationalunit=? or pc1_0.id in ((select puca1_0.clientapplication from ORGANIZATIONAL_UNIT_CLIENT_APPLICATION puca1_0 where puca1_0.organizationalunit=?))) and (pc1_0.id in ((select pc2_0.client from GROUP_CLIENT pc2_0 where pc2_0.khgroup=?)) or pc1_0.id=?) and pc1_0.id=? and pc1_0.DTYPE='POAuth2Client'))) and pr1_0.uuid=? order by pr1_0.id fetch first ? rows only] [FATAL: simple query "BEGIN" arrived before ending an extended query message] [n/a]
	at [email protected]//org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202)
	at [email protected]//org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:375)
	at [email protected]//org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:143)
	< cut >
	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:256)
	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:101)
	at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:395)
	at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:861)
	at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.exception.GenericJDBCException: JDBC exception executing SQL [select pr1_0.id,pr1_0.color,pr1_0.createdAt,pr1_0.createdBy,pr1_0.derived,pr1_0.endDate,pr1_0.filename,pr1_0.lastModifiedAt,pr1_0.lastmodifiedby,pr1_0.metadata,pr1_0.name,pr1_0.parent,pr1_0.recordKey,pr1_0.shareEndTime,pr1_0.url,pr1_0.username,pr1_0.uuid,pr1_0.vault,pr1_0.version,pr1_0.warningPeriod from VAULT_RECORD pr1_0 where (pr1_0.vault in ((select p2_0.vault from KHGROUP p2_0 where (p2_0.organizationalunit=?) and (p2_0.id=?) and p2_0.id=?)) or pr1_0.vault in ((select vs1_0.vault from CLIENT_APPLICATION pc1_0 join KHGROUP o1_0 on o1_0.id=pc1_0.owner join VAULT_SECRETS vs1_0 on vs1_0.id=pc1_0.vaultsecrets where (o1_0.organizationalunit=? or pc1_0.id in ((select puca1_0.clientapplication from ORGANIZATIONAL_UNIT_CLIENT_APPLICATION puca1_0 where puca1_0.organizationalunit=?))) and (pc1_0.id in ((select pc2_0.client from GROUP_CLIENT pc2_0 where pc2_0.khgroup=?)) or pc1_0.id=?) and pc1_0.id=? and pc1_0.DTYPE='POAuth2Client'))) and pr1_0.uuid=? order by pr1_0.id fetch first ? rows only] [FATAL: simple query "BEGIN" arrived before ending an extended query message] [n/a]
	at [email protected]//org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:63)
	at [email protected]//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
	at [email protected]//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
	at [email protected]//org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.executeQuery(DeferredResultSetAccess.java:268)
	at [email protected]//org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.getResultSet(DeferredResultSetAccess.java:171)
	at [email protected]//org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.<init>(JdbcValuesResultSetImpl.java:74)
	at [email protected]//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.resolveJdbcValuesSource(JdbcSelectExecutorStandardImpl.java:355)
	at [email protected]//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:137)
	at [email protected]//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:102)
	at [email protected]//org.hibernate.sql.exec.spi.JdbcSelectExecutor.executeQuery(JdbcSelectExecutor.java:91)
	at [email protected]//org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:165)
	at [email protected]//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$1(ConcreteSqmSelectQueryPlan.java:152)
	at [email protected]//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:442)
	at [email protected]//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:362)
	at [email protected]//org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:380)
	at [email protected]//org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:143)
	at [email protected]//org.hibernate.query.Query.getResultList(Query.java:120)
	at deployment.keyhub-ear.ear//nl.topicus.cobra.dao.data.AbstractDAO.lambda$get$9(AbstractDAO.java:728)
	at deployment.keyhub-ear.ear//nl.topicus.cobra.dao.data.AbstractDAO.timed(AbstractDAO.java:1478)
	at deployment.keyhub-ear.ear//nl.topicus.cobra.dao.data.AbstractDAO.get(AbstractDAO.java:727)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at [email protected]//org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:35)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
	at [email protected]//org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:62)
	at [email protected]//org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:72)
	at [email protected]//org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:85)
	at [email protected]//org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:46)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:26)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:30)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:28)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
	at [email protected]//org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:35)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:34)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:39)
	at [email protected]//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at [email protected]//org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:184)
	... 235 more
Caused by: org.postgresql.util.PSQLException: FATAL: simple query "BEGIN" arrived before ending an extended query message
	at [email protected]//org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2734)
	at [email protected]//org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2421)
	at [email protected]//org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:372)
	at [email protected]//org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:518)
	at [email protected]//org.postgresql.jdbc.PgStatement.execute(PgStatement.java:435)
	at [email protected]//org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:196)
	at [email protected]//org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:139)
	at [email protected]//org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
	at [email protected]//org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.executeQuery(DeferredResultSetAccess.java:250)
	... 277 more
```

view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3724: Regression: FATAL:  simple query "BEGIN" arrived before ending an extended query message
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox