[r2dbc] getRowsUpdated() returns 0 for successful INSERT…SELECT — needs reliable written_rows
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
Comienza en ClickHouseResult y sigue cómo ClickHouseResponseSummary.getProgress(), getStatistics() y el getWrittenRows() de nivel superior proporcionan UpdateCount. Reproduce una consulta INSERT INTO … SELECT usando el transporte HTTP y compara getRowsUpdated() con el valor final de written_rows. Se considera completado cuando el valor autoritativo elegido posterior a la finalización se expone de forma fiable y existe cobertura de regresión para un INSERT…SELECT exitoso.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Java
- Estrellas
- 1.6k
- Forks
- 637
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 29
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ClickHouse/clickhouse-java
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
ClickHouse/clickhouse-java#3111 ·
-
area:data-type bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ClickHouse/clickhouse-java#3098 · 1 comentario ·
-
bug client-api-v2 test
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
ClickHouse/clickhouse-java#3076 ·
-
area:sql-parser bug client-v1
Dificultad 1/5 1-3 horas Aptitud para principiantes 92/100
ClickHouse/clickhouse-java#3066 ·
-
area:general bug client-api-v2 jdbc jdbc-v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
ClickHouse/clickhouse-java#3063 ·
Todos los issues de ClickHouse/clickhouse-java
Issues similares
-
area-deployment area-integrations triage:bot-seen
Dificultad 2/5 Medio día Aptitud para principiantes 86/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful Abiertoarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100