Repository navigation
Do not leave a FileLog table locked after a failed read - #123395
alexey-milovidov merged 1 commit into
Conversation
FileLogSource takes a reader slot in its constructor (increaseStreams) and releases it only in close(). The destructor called close() only if ISource::finished was not set, but ISource::work() sets that flag when generate() throws. So any exception inside the source (a line that does not parse with the default handle_error_mode, a partially written last line, an I/O error) left running_streams at 1 forever: every later streamToViews() logged "Another select query is running on this table" and every direct SELECT failed with CANNOT_SELECT until the server was restarted. The source now keeps its own closed flag, and close() releases the slot with SCOPE_EXIT, so it is also released when closeFilesAndStoreMeta() throws. close() no longer writes ISource::finished; ISource::work() sets it after generate() returns the empty chunk. The leak dates from 7b1d463, which moved reduceStreams() from the unconditional destructor into the finished-guarded path. Related: ClickHouse#123368 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; 2 rounds, 1 finding) plus my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261002-020400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261002-004503 |
|
Workflow [PR], commit [d1cc314] Summary: ✅
AI ReviewSummaryThis PR fixes the Missing context / blind spots
Final Verdict
LLVM Coverage ReportMeasured on commit d1cc314.
Changed lines: Changed C/C++ lines covered: 7/7 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 16 s compile time in total, 8 of them have a recent master baseline. |
Related: #123368
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
FileLogtable that stopped reading all of its files forever after a single read error (such as a line that failed to parse or a partially written last line): every later poll reportedAnother select query is running on this tableand every directSELECTfailed withCANNOT_SELECTuntil the server was restarted. Related to #123368.Description
On 26.8 (also 26.3), after one read of a
FileLogtable fails, the table never reads again: materialized views stop receiving rows and everySELECTfails withCANNOT_SELECTuntil the server restarts. This is what makes item 1 of #123368 permanent.Cause:
FileLogSourcereleases its reader slot (StorageFileLog::reduceStreams) only inclose(), and its destructor calledclose()onlyif (!finished). That flag isISource::finished, whichISource::work()also sets whengenerate()throws, so after any exception inside the source the slot was never released.Change:
FileLogSourcekeeps its ownclosedflag, andclose()releases the slot withSCOPE_EXIT, so it is also released when storing the metadata throws.After the fix a failed read behaves like an error raised later in the pipeline (for example by a materialized view's
SELECT) already does on master: the rows read in that batch are not retried, and the table keeps reading. An incomplete last line is re-read on the next poll. Isolating one bad file from the others, and not raising an error for an incomplete last line at all, are separate PRs for #123368.Validation: the new test fails on master with
CANNOT_SELECTand passes 50/50 with randomized settings; the existingFileLogtests pass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123395]
Version info
26.10.1.1327-master(included in26.10and later)