[r2dbc] getRowsUpdated() returns 0 for successful INSERT…SELECT — needs reliable written_rows
还没有人认领这个 Issue。
评估
调研方向
从 ClickHouseResult 开始,跟踪 ClickHouseResponseSummary.getProgress()、getStatistics() 和顶层的 getWrittenRows() 如何提供 UpdateCount。使用 HTTP transport 重现一条 INSERT INTO … SELECT 查询,然后将 getRowsUpdated() 与最终的 written_rows 值进行比较。当选定的完成后权威值能够可靠地公开,并且有针对成功 INSERT…SELECT 的回归覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Summary
ClickHouseResult.getRowsUpdated() in clickhouse-r2dbc returns 0 for
successful INSERT INTO … SELECT FROM … queries that did write rows. This
makes it impossible to reliably distinguish "INSERT…SELECT wrote 0 rows
because the SELECT produced none" from "INSERT…SELECT wrote N rows but the
driver reported 0" at the application layer.
The same row count appears correctly in system.query_log.written_rows
server-side, and the HTTP X-ClickHouse-Summary header also carries an
accurate written_rows once the query finishes. The information exists; the
driver just doesn't expose it via the standard R2DBC Result.getRowsUpdated()
contract for this query shape.
Reproduction
- Driver:
com.clickhouse:clickhouse-r2dbc:0.9.0(also reproduces on 0.8.x) - Server: ClickHouse 25.3
- Query shape:
INSERT INTO target_table (...) SELECT ... FROM source_table WHERE ... - Connection settings:
async_insert=1, wait_for_async_insert=1
(per docs,async_insertis a no-op forINSERT…SELECT, but we set it
globally for theINSERT VALUESpath on the same connection)
Flux.from(statement.execute())
.flatMap(Result::getRowsUpdated) // emits 0 even when N rows were inserted
.reduce(0L, Long::sum)
// observed: returns 0
Verifying server-side after the query finishes:
SELECT written_rows
FROM system.query_log
WHERE query_id = '...' AND type = 'QueryFinish';
-- returns N (the correct count)
Root cause
Looking at ClickHouseResult constructor (current main):
Mono<? extends UpdateCount> updatedCount = Mono.just(response)
.map(ClickHouseResponse::getSummary)
.map(ClickHouseResponseSummary::getProgress)
.map(ClickHouseResponseSummary.Progress::getWrittenRows)
.map(UpdateCount::new);
The driver reads written_rows from Summary.getProgress(), which is the
interim progress event snapshot — not the final summary. For
INSERT…SELECT queries, a definitive post-completion written_rows is
typically reflected in Summary.getStatistics() (or in a final progress
event that doesn't always land before the subscriber observes completion).
ClickHouseResponseSummary exposes both getProgress() and getStatistics(),
and the top-level getWrittenRows() delegates to progress.
Use case
Detecting at the application layer when an INSERT…SELECT wrote zero rows
(to surface inconsistency conditions before committing dependent state).
Since getRowsUpdated() can return 0 even on success, the check fires
false positives.
Asks
Any one of the following would unblock us:
- Source
getRowsUpdated()fromSummary.getStatistics()(or whichever
field is authoritative post-completion) instead of fromSummary.getProgress(). - Expose the raw
ClickHouseResponseSummaryfromClickHouseResult(or a
similar handle), so callers can read the final fields themselves. - Document the current semantics so applications know not to rely on
getRowsUpdated()forINSERT…SELECT.
Happy to send a PR for (1) or (2) — please confirm which direction you'd
prefer.
Environment
clickhouse-r2dbc: 0.9.0clickhouse-client/clickhouse-http-client: 0.9.0- ClickHouse server: 25.3.x
- Connection: HTTP transport
- 主要语言
- Java
- 星标
- 1.6k
- 派生
- 637
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 29
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ClickHouse/clickhouse-java 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
ClickHouse/clickhouse-java#3111 ·
-
area:data-type bug
难度 2/5 1-3 小时 新手友好度 78/100
ClickHouse/clickhouse-java#3098 · 1 条评论 ·
-
bug client-api-v2 test
难度 2/5 1-3 小时 新手友好度 92/100
ClickHouse/clickhouse-java#3076 ·
-
area:sql-parser bug client-v1
难度 1/5 1-3 小时 新手友好度 92/100
ClickHouse/clickhouse-java#3066 ·
-
area:general bug client-api-v2 jdbc jdbc-v2
难度 2/5 1-3 小时 新手友好度 88/100
ClickHouse/clickhouse-java#3063 ·
查看 ClickHouse/clickhouse-java 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
objectionary/jeo-maven-plugin#1811 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
hiero-ledger/hiero-block-node#3693 ·
-
area/dependencies kind/cve severity/critical source/scan-dependencies status/triage
难度 2/5 1-3 小时 新手友好度 82/100
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 84/100
-
proposal
难度 2/5 1-3 小时 新手友好度 78/100
beemdevelopment/Aegis#1840 ·