Skip to content

Tolerate a broken txn_version.txt.tmp when loading a part - #110519

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix/tolerate-broken-tmp-txn-version-diagnostic
Jul 17, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix/tolerate-broken-tmp-txn-version-diagnostic

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

A leftover txn_version.txt.tmp on a part is an artifact of an interrupted write, so not only its content but even the disk-level metadata describing it can be broken. On an object storage disk with local metadata, a raw or partially written metadata file for it made getFileSize throw CANNOT_PARSE_INPUT_ASSERTION_FAILED from DiskObjectStorageMetadata::deserialize inside VersionMetadataOnDisk::removeTmpMetadataFile, failing the part load, the table load, and with it the server startup (Cannot start clickhouse-server).

The read there is purely diagnostic — the content is dumped to the log right before the file is removed, and VersionMetadataOnDisk::loadMetadata already documents the content as expendable ("Content of *.tmp file may be broken"). Make it best-effort: on failure, log the exception and proceed with the removal, which is already tolerant to such files (UnlinkFileOperation reads the disk-level metadata with tryReadMetadataFile).

Seen in stress tests when the harness kills the server inside the window in which 04492_attach_as_replicated_clears_tmp_txn_version keeps a raw txn_version.txt.tmp on a part: Stress test (arm_debug) report. The same signature hit at least three other PRs within the last 30 days (#107363, #86353, #108773 in addition to #106189). This is not CI-only: any server restart that encounters this on a real deployment hits the same startup failure, so this is a genuine bug fix rather than a CI-only change.

Added test_broken_tmp_txn_version_startup: a transactional insert on a local object storage disk, a raw overwrite of the txn_version.txt.tmp metadata file, and a hard restart. Without the fix the server fails to load the table with the exact Cannot parse input error from the report; with the fix it starts, the committed part survives, and the leftover file is cleaned up.

Related: #106189
Related: #108772

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed server startup failure for MergeTree tables on object storage disks when a leftover txn_version.txt.tmp file has broken disk-level metadata.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.1120 (included in 26.7 and later)

A leftover `txn_version.txt.tmp` on a part is an artifact of an interrupted
write, so not only its content but even the disk-level metadata describing it
can be broken. On an object storage disk with local metadata, a raw or
partially written metadata file for it made `getFileSize` throw
`CANNOT_PARSE_INPUT_ASSERTION_FAILED` from
`DiskObjectStorageMetadata::deserialize` inside
`VersionMetadataOnDisk::removeTmpMetadataFile`, failing the part load, the
table load, and with it the server startup ("Cannot start clickhouse-server").

The read there is purely diagnostic (the content is dumped to the log before
the file is removed), so make it best-effort: on failure, log the exception
and proceed with the removal, which is already tolerant to such files
(`UnlinkFileOperation` reads the disk-level metadata with
`tryReadMetadataFile`).

Seen in stress tests when the harness kills the server inside the window in
which `04492_attach_as_replicated_clears_tmp_txn_version` keeps a raw
`txn_version.txt.tmp` on a part, e.g.
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106189&sha=73e731bf28d09bb59fa7e7921f58be9d812cf201&name_0=PR&name_1=Stress%20test%20%28arm_debug%29
on #106189, and the same
signature on at least three other PRs within the last 30 days.

Add `test_broken_tmp_txn_version_startup`: a transactional insert on a local
object storage disk, a raw overwrite of the `txn_version.txt.tmp` metadata
file, and a hard restart. Without the fix the server fails to load the table
with the exact `Cannot parse input` error from the report; with the fix it
starts, the committed part survives, and the leftover file is cleaned up.
@clickhouse-gh

clickhouse-gh Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a518f99]

Summary: ✅


AI Review

Summary

This PR makes the diagnostic read of a leftover txn_version.txt.tmp best-effort during part load, so broken object-storage local metadata no longer turns a stale temporary file into a startup failure, and it adds an integration test that exercises the reported restart path. After checking the current diff, the surrounding unlink path, the prior discussion, and the current CI report, I did not find remaining correctness, compatibility, or coverage problems in the patch.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 15, 2026
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-ci labels Jul 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.90% 85.90% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 78.10% 78.00% -0.10%

Changed lines: Changed C/C++ lines covered: 18/22 (81.82%) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@alexey-milovidov alexey-milovidov self-assigned this Jul 17, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 17, 2026
Merged via the queue into master with commit 1310d6c Jul 17, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/tolerate-broken-tmp-txn-version-diagnostic branch July 17, 2026 22:18
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 17, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ken-tmp-txn-version-diagnostic

Tolerate a broken txn_version.txt.tmp when loading a part
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants