Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

PG client: cached prepared statement is never evicted after a schema change on tables with 10+ columns

Cerrado
#1,751 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@tsegismont ya está trabajando en esto.

Desde el 12/10/2026.

  • #1752 de @Meemaw — fusionado

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
18/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
java, postgresql
Área
databases

Línea de trabajo

Start in ExtendedQueryPgCommandMessage, where TABLE_SCHEMA_CHANGE_ERROR_MESSAGE_PATTERN uses \d, which matches only one digit under String.matches. Replace it with \d+ for both counts, then check PreparedStatementCachedTest for the reproduction steps. Pull request #1752 already contains this fix and is open, so review or follow up on it rather than starting a new change.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Version

5.1.7 through 5.2.1, and current master (3967b19e).

Context

ExtendedQueryPgCommandMessage evicts a cached prepared statement when the server reports a table schema change:

private static final String TABLE_SCHEMA_CHANGE_ERROR_MESSAGE_PATTERN = "bind message has \\d result formats but query has \\d columns";
...
return errorResponse.getMessage().matches(TABLE_SCHEMA_CHANGE_ERROR_MESSAGE_PATTERN) || ...

\d matches a single digit, and String.matches requires the whole message to match. So for any query that returns 10 or more columns, for example bind message has 15 result formats but query has 16 columns, the pattern doesn't match and no InvalidCachedStatementEvent is fired. The stale statement stays in the cache, and every later execution of that SQL on the connection fails with the same 08P01 until the connection is closed.

Against plain Postgres a cached statement usually fails with cached plan must not change result type instead, which is handled. The bind message has N result formats form shows up when something parses the named statement again after the schema change, before the client's Bind. AWS RDS Proxy does this when it moves the statement to a backend connection. We hit it in production: after an ALTER TABLE ... ADD COLUMN on a 26-column table, pooled connections behind RDS Proxy kept failing with bind message has 26 result formats but query has 27 columns for several minutes, until the pool recycled them.

Steps to reproduce

Against plain Postgres, with setCachePreparedStatements(true) and a single connection:

  1. CREATE TABLE t (id int PRIMARY KEY, c1 int, ..., c9 int) (10 columns), then insert a row.
  2. preparedQuery("SELECT * FROM t WHERE id=$1").execute(...) succeeds and caches the statement.
  3. ALTER TABLE t ADD COLUMN c10 int.
  4. To simulate the proxy, look up the statement name in pg_prepared_statements and run DEALLOCATE "<name>"; PREPARE "<name>" (int4) AS SELECT * FROM t WHERE id=$1.
  5. Execute the prepared query: it fails with bind message has 10 result formats but query has 11 columns (expected).
  6. Execute it again: it fails with the same error. It should succeed, because the statement should have been evicted in step 5.

With a table of 9 or fewer columns, step 6 succeeds.

Fix

Use \d+ for both counts. I have a branch with the one-line change and a regression test in PreparedStatementCachedTest covering the steps above, and will open a PR.

Lenguaje dominante
Java
Estrellas
912
Forks
215
Merge medio
20 h 49 min
PR fusionados (30 d)
44

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de eclipse-vertx/vertx-sql-client

Todos los issues de eclipse-vertx/vertx-sql-client

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.