PgBouncer transaction pooling: `prepare` runs outside the read transaction and can land on another backend
维护者通常 1 天内回复
@sprihaanand-juspay 已经在做这个了。
开始于 2026年11月27日。
评估
这个 Issue 还没有评估数据。
描述
Summary
STREAMGRES_READ_PG_DSN is documented as able to point at PgBouncer in transaction pooling mode (docs/deploy.md), and reads are designed around that: one BEGIN … SET TRANSACTION SNAPSHOT …; SELECT …; COMMIT transaction, so the PgBouncer backend stays assigned through snapshot import and query.
That holds on the fast path, but not on the slow one. When a table has a result type the driver does not already know (driver_knows is false — enums, extension types, hand-declared columns without a type OID), Pool::read resolves the result types with client.prepare(sql) before the transaction is opened:
// src/sync/pg/mod.rs — read()
let statement = if driver_knows {
None
} else {
match client.prepare(sql).await { // <-- outside the transaction
Ok(statement) => Some(statement),
...
}
};
// then: batch_execute("BEGIN … SET TRANSACTION SNAPSHOT …") + query_raw + COMMIT
Under transaction pooling that prepare is a standalone round trip on a pooled client connection. PgBouncer may assign it a different backend than the one that later runs BEGIN … SET TRANSACTION SNAPSHOT, and a prepared statement is backend-local, so the subsequent query_raw can fail (prepared statement "…" does not exist), or PgBouncer can reject the prepare outright (prepared statements are not supported in transaction pooling mode, depending on version and max_prepared_statements). Either way, the read fails for tables whose types are not in the driver's known-type table — exactly the tables the prepare path exists for.
The driver_knows == true path is unaffected: it streams through query_typed_raw and never prepares.
- 主要语言
- Rust
- 星标
- 129
- 派生
- 7
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
juspay/streamgres 的其他 Issue
-
Make the top-L client diff cost depend on what changed, not on the limit可能已有人在做 @SahilKhan101 于 2 天前认领。 未关闭enhancement
juspay/streamgres#64 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Query optimisation: share initial snapshots across LIMIT variants of the same query (donor windows)可能已有人在做 @sprihaanand-juspay 于 3 天前认领。 未关闭
juspay/streamgres#58 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 一周以上 新手友好度 38/100
juspay/streamgres#56 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
juspay/streamgres#55 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
juspay/streamgres#49 ·
维护者通常 1 天内回复
查看 juspay/streamgres 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
area: settings bug Haiku review: no-score ui
难度 2/5 1-3 小时 新手友好度 78/100
MMFoundation/WallpaperMachine#346 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
rubys/roundhouse#2473 ·
-
bug mod: quantum info
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复