Repository navigation
Conversation
A stalled FileLog table (a partial last line, an unreadable file, any read or insert error) leaves a trace only in the server log. The new table has one row per file of each FileLog table: path, inode, the read offset, the live file size (so the unread part), the number of records read, the last poll time, the last exception and its time, and whether the table is consuming the file or is stuck on it. The state cannot be read from `file_infos`: a background round holds `file_infos_mutex` for its whole duration, and the direct SELECT readers mutate `file_infos` without it. So StorageFileLog keeps a small snapshot under its own mutex, written where that state already changes: the file set (constructor and `updateFileInfos`, which also restarts the statistics of a re-added inode, as the meta is restarted at offset 0), the stored offsets (`storeMetas`, `closeFilesAndStoreMeta`), the start of a read of a changed file (`openFilesAndSetPos`), the record counter (`FileLogConsumer::readNewRecords`), and the outcome of each background round. A failed round marks every file it read as stuck, because on master one error fails the round's whole insert pipeline; a later successful round that includes the file marks it consuming again. Rows are shown only for tables with `SHOW TABLES`, as in `system.kafka_consumers`. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`threadFunc` records the round's exception from inside its catch handler, where the memory tracker may still throw: a MEMORY_LIMIT_EXCEEDED escaping a BackgroundSchedulePool task aborts debug builds and skips the reschedule in release. Block it for the copy, as `KeeperHandlingConsumer::rollbackToCommittedOffsetsNoThrow` does. A table of a `lazy_load_tables` database is attached as a `StorageTableProxy`, so the system table never showed it, even after the stand-in was loaded and its FileLog was ingesting. Unwrap a proxy that is already loaded; a stand-in that is not loaded has no read state and is still skipped, without loading it. 05316 now also checks that `file_size` is NULL for a renamed file whose name was reused before the table processed the rename, and the lazy table case. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`CREATE TEMPORARY TABLE ... ENGINE = FileLog` is accepted, and the temporary tables of every session live in the one shared `_temporary_and_external_tables` database, so a user with `SHOW TABLES` saw the paths, offsets and exception texts of other sessions' temporary FileLog tables. Skip that database, as `system.tables`, `system.columns` and the other per-table system tables do. 05316 now also processes the rename of a file whose name was reused and checks that the renamed file keeps its offset and counters under its new name while the new file starts from zero, and that a temporary table is not shown. Drop unused column includes. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`fillData` called `getTablesIterator` on every database, including remote ones such as `MySQL` and `PostgreSQL`, which cannot hold a FileLog table. Listing the tables of a `MySQL` database connects to the remote server and throws `ALL_CONNECTION_TRIES_FAILED` when it is unreachable, so every `SELECT` from `system.filelog_files` failed, even with a filter on `database` (the filter is not pushed into `fillData`); a `PostgreSQL` database cost one remote fetch per table on every `SELECT`. Skip databases with `isExternal()`, as `system.mutations`, `system.replicas` and the other engine-specific system tables do. 05318 attaches a `MySQL` database pointing at a closed port and checks that the table can still be read. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`current_offset` of a loaded table comes from the stored metadata, while `num_records_read`, `last_poll_time`, `last_exception` and `state` start over. No test reloaded a table with a nonzero stored offset: the lazy arm reads before it looks, and every other offset assertion follows a read, after which the offset is overwritten anyway. So a load that did not copy the stored offset passed every test while showing the whole file as unread after each restart. 05316 now detaches and attaches the table after the processed rename and checks that every file keeps its offset with zero records read. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A file that was read to its end is `NO_CHANGE`, and the watcher event of a later append is applied only by `updateFileInfos()` at the end of `streamToViews()`. So when a round fails before it reads, for example because building the sink of a view's destination throws, the file is not part of the round: the catch in `threadFunc()` marked nothing, the queued event was never applied, and the file stayed `consuming` with an empty `last_exception` while its new bytes were never read. `setFilesException()` now also marks every tracked file that still has unread bytes on disk (same inode, size above the stored offset), so such a stall shows as `stuck` with the exception. Files of the round are marked as before. The descriptions of `last_exception` and `state` and the table documentation say so. 05317 swaps the destination of a view for a `Merge` table, which rejects inserts while the insert is built, after the first record is consumed, appends a record and checks that the file becomes `stuck` with `NOT_IMPLEMENTED` and 8 unread bytes. Related: ClickHouse#123368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review: my own cold review in each of seven rounds, plus an independent model (engine: codex) in five of them; 13 findings. Bounce cap reached - published as-is; residual findings listed below (rows 7, 8 and 13, all nits). The last round's change (row 9) was checked by my own review and its test, without a new second-model run.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261002-132600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261002-125900 |
|
Workflow [PR], commit [1d91fc7] Summary: ❌
AI ReviewSummaryThis PR adds Findings❌ Blockers
Final Verdict❌ Changes requested. The reused-inode |
| it->second = FileMeta{.file_name = file_name}; | ||
| else | ||
| file_infos.meta_by_inode.emplace(inode, FileMeta{.file_name = file_name}); | ||
| eraseFileStatistics(inode); |
There was a problem hiding this comment.
This only resets the per-inode snapshot for DW_ITEM_ADDED. DW_ITEM_MOVED_TO is also a "new file" path when producers write in a staging directory and then rename into the watched directory. If the deleted watched file's inode has already been recycled for that staging file, the meta_by_inode hit in the DW_ITEM_MOVED_TO branch treats it as a rename, keeps the old last_writen_position and num_records_read, and can seek past the beginning of the new file.
Please reset or positively pair true renames there as well (for example by plumbing a rename cookie through the watcher), and add a focused test for the atomic-rename case.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (+234.35 KiB total), 1 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units13 translation units recompiled, 63 s compile time in total, 12 of them have a recent master baseline. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new storage_casts style rule requires castStorage for engines that can be deferred. DeferredTable::Skip keeps the previous behaviour: a lazily loaded FileLog table is shown once loaded, and the listing never loads one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since a file that cannot be opened is skipped and retried instead of failing the round, such a file showed `consuming` with no exception. Record the open error and show the file as `stuck` until it opens. A single-file table (or a symlink) whose file was recreated with a new inode kept the old inode's row with a NULL size and frozen counters, as `updateFileInfos` never resyncs the statistics of a single-file table. Move the row to the new inode when the file is reopened. A file truncated in place is read again from its start, so show 0 as its offset until then instead of an offset past its end. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…round fails A file that could not be opened is retried by every round, so it belongs to the files of the round: a successful round now clears its `stuck` state like that of any other file it read. And a round that fails before reading now also marks a file truncated in place, which is read again from its start. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 1d91fc7Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261011-043008 |
Related: #123368
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
system.filelog_filestable with one row per file of eachFileLogtable: the read offset, the current file size (so the unread part), the number of records read, the last poll time, the last exception and whether the table is consuming the file or is stuck on it.Description
Item "Stalls are silent - add observability" of #123368: when a
FileLogtable stops ingesting, the only trace today is the server log. The new table has one row per (table, file):path,inode,current_offset, the livefile_size(file_size - current_offsetis the lag),num_records_read,last_poll_time,last_exceptionwith its time, andstate(consuming/stuck). Rows are shown only for tables withSHOW TABLES, as insystem.kafka_consumers; temporary tables are not shown, and databases of external engines (MySQL,PostgreSQL) are not read.StorageFileLogkeeps a per-inode snapshot under its own mutex, since a background round holdsfile_infos_mutexfor its whole duration and the directSELECTreaders changefile_infoswithout it. A failed round marks every file it read, and every file with unread bytes (a round can fail before it reads, e.g. on a destination that rejects inserts), asstuck, since on master one error fails the round's whole insert; the next successful round that includes the file clears it. A file that cannot be opened (every round retries it) isstuckwith that error until it opens. A file recreated with a reused inode starts over, one recreated with a new inode gets a new row, and a file truncated in place shows offset 0, since it is read again from its start.On the issue's partial-last-line repro the row shows
state = stuck,CANNOT_READ_ALL_DATAand 52 unread bytes.Tests:
05316(directSELECT: offsets, sizes, counters, added/removed/renamed/recreated/truncated files, a file that cannot be opened, a reload, access, temporary tables, alazy_load_tablestable),05317(materialized view:stuckon a failed read, on a round failing before it, also after a truncation, and on a file that cannot be opened, thenconsumingagain) and05318(an unreachableMySQLdatabase). All fail on master (UNKNOWN_TABLE) and passed 50/50 randomized runs.Workflow [PR]
Sync PR [sync-upstream/pr/123542]