Repository navigation
Conversation
StreamingFormatExecutor reuses one input format for all entries of an asynchronous insert batch (and for Kafka, NATS and RabbitMQ messages) and calls resetParser() between them, also after a parse error. IRowInputFormat::resetParser() zeroes total_rows, so readPrefix() parses the next input's header again, but NpyRowInputFormat had no override, so read_rows kept the count of the previous inputs. Since ClickHouse#101179 (first in 26.4) readRow() stops at read_rows >= shape[0] instead of at eof (needed for zero-size elements), so every later input read only shape[0] - read_rows rows, often none, and the entries were still logged Ok. After a failed input the next valid one was cut too. Reset read_rows and counted_rows in a resetParser() override. 26.3 is correct because it stopped at eof. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings, 1 round) plus my own cold review (1 nit, dropped).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261103-215400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261103-213300 |
|
Workflow [PR], commit [ed01bbe] Summary: ✅
AI ReviewSummaryThis PR fixes silently dropped rows when a Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline. |
|
Replaced by #129209, which fixes this class for every input format in |
…self StreamingFormatExecutor (async insert flushes, Kafka, Kafka2, NATS, RabbitMQ, FileLog) kept one input format object for many independent inputs and called resetParser() between them, trusting every format to bring itself back to the state of a fresh object. Nothing enforced that: 32 of the 82 input format names kept some per-input field (One `done`, Npy `read_rows`, MySQLDump `table_name` and column mapping, SQLite flags and database, JSON `parse_as_json_each_row`, DWARF section extractors, TSV `first_row`, CustomSeparated `columns` and the detected header, RowBinaryWithNamesAndTypes `read_data_types`, Template `row_num`), so a later input of an async insert batch or a later message lost rows, was rejected, or was parsed with the previous input's state. Per-format resetParser fixes (ClickHouse#128943, ClickHouse#129109, ClickHouse#129140) leave the default unsafe for the next format and the next field. Invert the default: a format is reused only when its name is registered with FormatFactory::markInputFormatSupportsResetParser; any other format is released after each input and created anew for the next one. The executor now takes a format creator and an AddingDefaultsTransform creator (the transform holds a reference to the format). The streaming engines compute their single-threaded parser resources once and share them between created formats. Marked: the 50 names whose reset is complete and 26 hot names completed here with one statement each (TSV first_row, CustomSeparated columns, WithNamesAndTypes is_header_detected, RowBinary read_data_types, Template row_num). Reuse matters for them: a fresh CapnProto, Template, Protobuf, Regexp or AvroConfluent object reads or compiles schemas. Not marked, so re-created with no per-format code: One, Npy, MySQLDump, SQLite, JSON, DWARF. DWARF's incomplete resetParser is deleted. 02187_async_inserts_all_formats now also inserts every format as one batch of two different inputs, plus targeted cases for the leaks that a same-shaped pair does not show, and a FileLog case. Closes ClickHouse#122351 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed lost rows when several
Npyinputs are parsed by the same format, as with the entries of one asynchronous insert batch: every input after the first one was cut by the row count of the inputs before it, and the lost rows were not reported.Description
Related: #128943 (the same defect class in
MsgPack, whose description noted this one).On 26.10.2.103, two asynchronous
Npyinserts that land in one batch insert only the first one's rows;system.asynchronous_insert_logreports bothOk. For example, entries of 2, 3 and 1 rows give 3 rows instead of 6. 26.3 is correct: this is a regression from #101179 (26.4).StreamingFormatExecutorreuses one input format for all entries of a batch (and, by the same code, for Kafka, NATS and RabbitMQ messages) and callsresetParserbetween them, also after a parse error. Since #101179,NpyRowInputFormat::readRowstops atread_rows >= shape[0], butread_rowswas never reset, so each later input read onlyshape[0] - read_rowsrows. After a failed input the next valid one was cut as well.NpyRowInputFormat::resetParsernow resetsread_rowsandcounted_rowsafter the base reset. File, URL and S3 reads build one format per file and are unchanged.The new test queues entries of 2, 3 and 1 rows, and a truncated entry followed by a valid one, into one batch each. On master it gives
[1,2,3]and[]; with the fix it passes 50/50 with randomized settings.SQLite,MySQLDumpandOnedrop or reject later inputs of a batch in the same way; not addressed here.Workflow [PR]
Sync PR [sync-upstream/pr/129109]