Repository navigation
FileLog on macOS: read a file moved back into the directory from the start when a link outside kept its inode - #133904
Conversation
05319_file_log_rename_in_reused_inode timed out in Fast test (arm_darwin) of ClickHouse#117738: one macOS scan saw a.csv gone and b.csv, moved in from a hard link outside the directory, with the same inode, diffed them as MOVED_FROM a.csv + MOVED_TO b.csv, and StorageFileLog kept a.csv's offset, skipping rows of b.csv. ClickHouse#123593 made is_rename refuse a name in deleted_files as a rename source. Before ClickHouse#125794 every NOTE_DELETE of a watched descriptor put its name there; ClickHouse#125794 (4d75ef8) returns early while the file still has links, because kqueue reports an unlink of any name to every descriptor of the file and the scan has to find which name went away (hidden excluded aliases of 05316_file_log_globs). When the remaining link is outside the directory, nothing recorded the unlink any more. Record the inode in that branch (unlinked_inodes), and in is_rename refuse the pair when the inode's current name matches the path: the scan lists every matching name and is_rename requires one listed name per side, so such a name was not a link of the file at the last scan and the file came back, i.e. it is new here, as on Linux (an IN_MOVED_TO without its IN_MOVED_FROM is ADDED). An excluded current name can be a hidden alias and keeps ClickHouse#125794's behaviour. The set lives next to deleted_files: kept across discarded and failed passes, cleared after a committed one, the first snapshot included (its listing already reflects every unlink recorded before it, and it pairs nothing). The unlink is drained before the diff (scanFilesAndUpdateWatches drains before syncFileWatches closes descriptors), so the decision does not depend on scan timing. The test gains the same steps in one process so a macOS scan sees the unlink and the move-in together; the new content is longer than c.csv's offset, so a carried- over offset gives wrong rows (checked on Linux with a same-inode rename, which keeps the offset: only 110 is read). 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 findings, then 0 on the re-review of the fix) plus my own review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261123-220900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261123-210205 |
|
Workflow [PR], commit [f9a2299] Summary: ✅
AI ReviewSummaryThe PR prevents macOS Missing context / blind spots
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 units6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline. |
Algunenano
left a comment
There was a problem hiding this comment.
I feel this code keeps getting more and more complex (partially my fault) and I doubt it has many users
75a9537
Related: #117738 (comment)
Related: #125794
Related: #123593
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
05319_file_log_rename_in_reused_inodetimed out inFast test (arm_darwin)of #117738 (report). One macOS scan sawa.csvgone andb.csv, moved in from a hard link outside the directory, with the same inode, and paired them as a rename (onItemMovedFrom a.csv,onItemMovedTo b.csvin one batch), sob.csvwas read froma.csv's offset and rows were skipped.Since #125794, a
NOTE_DELETEof a file that still has another link no longer records anything, so the veto from #123593 does not fire. The watcher now records the inode of such a file, andis_renamedoes not pair it when its new name matches the path: the last scan listed every matching name, so the name is new to the file, which is read from the start. An excluded name (a hidden alias) is unchanged.A file renamed inside the directory in the same scan as another of its links is removed is read again from the start, as before #125794. A file moved back under its own old name in one scan is still kept as the same file on macOS, as on master.
The test gains the same steps run in one process, so a macOS scan sees them together more often. Validation: macOS cross-compile of all FileLog objects with CI's flags, Linux 50/50 of the test; the macOS run is this PR's
Fast test (arm_darwin).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/133904]
Version info
26.12.1.409-master(included in26.12and later)