PG client: cached prepared statement is never evicted after a schema change on tables with 10+ columns
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 18/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
CREATE TABLE t (id int PRIMARY KEY, c1 int, ..., c9 int)(10 columns), then insert a row.preparedQuery("SELECT * FROM t WHERE id=$1").execute(...)succeeds and caches the statement.ALTER TABLE t ADD COLUMN c10 int.- To simulate the proxy, look up the statement name in
pg_prepared_statementsand runDEALLOCATE "<name>"; PREPARE "<name>" (int4) AS SELECT * FROM t WHERE id=$1. - Execute the prepared query: it fails with
bind message has 10 result formats but query has 11 columns(expected). - 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.
- Ngôn ngữ chính
- Java
- Star
- 912
- Fork
- 215
- Merge trung bình
- 19 giờ 40 phút
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipse-vertx/vertx-sql-client
-
enhancement help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
eclipse-vertx/vertx-sql-client#1714 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
eclipse-vertx/vertx-sql-client#1709 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[MSSQL] Support for Windows AD access tokens to connect to MSSQL databaseCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởenhancement help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
eclipse-vertx/vertx-sql-client#1694 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
eclipse-vertx/vertx-sql-client#1665 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support streaming in SqlTemplateCó thể đã có người làm @zZHorizonZz đã nhận 218 ngày trước. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
eclipse-vertx/vertx-sql-client#1624 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của eclipse-vertx/vertx-sql-client
Issue tương tự
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
kestra-io/plugin-aws#816 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
kestra-io/plugin-kestra#200 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
opensearch-project/search-relevance#618 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Studio][Bug] Invalid ACL wildcard entries inflate the risk scoreCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/rocketmq-dashboard#6716 ·
Maintainer thường phản hồi trong vòng 3 ngày