Skip to content

Fix empty committed snapshots: Restore behaviour of writing to temporary uncommitted file and renaming #7029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 3, 2025

Conversation

eddyashton
Copy link
Member

#5273 introduced an unnoticed break from our documented behaviour - snapshots were written directly to a .committed file (in multiple fwrite() calls), rather than being renamed from an intermediate file. This means any consumer of .committed snapshots could read invalid files (incomplete, perhaps entirely empty, depending how they interleaved with the fwrite() calls and implicit flushing), and could not distinguish these from correct files without attempting to parse the file.

This PR modifies an existing e2e test to reproduce this behaviour - aggressively reading snapshots directly from the node's output directory, as they are being written. It also includes the fix of restoring the intermediate file - CCF will again (as documented) write to a temporary file snapshot_X-Y file, and then rename it to snapshot_X-Y.committed file once it is complete and ready for reading.

@eddyashton eddyashton requested a review from a team as a code owner June 2, 2025 10:42
@eddyashton eddyashton added auto-backport Automatically backport this PR to LTS branch 5.x-todo PRs which should be backported to 5.x labels Jun 2, 2025
@achamayou achamayou added the run-long-test Run Long Test job label Jun 2, 2025
Co-authored-by: Amaury Chamayou <[email protected]>
@eddyashton eddyashton added this pull request to the merge queue Jun 3, 2025
@eddyashton eddyashton removed this pull request from the merge queue due to a manual request Jun 3, 2025
@eddyashton eddyashton enabled auto-merge June 3, 2025 12:05
@eddyashton eddyashton added this pull request to the merge queue Jun 3, 2025
Merged via the queue into microsoft:main with commit d950184 Jun 3, 2025
15 checks passed
@eddyashton eddyashton deleted the restore_snapshot_rename branch June 3, 2025 13:08
eddyashton added a commit to eddyashton/CCF that referenced this pull request Jun 3, 2025
…ary uncommitted file and renaming (microsoft#7029)

Co-authored-by: Amaury Chamayou <[email protected]>
(cherry picked from commit d950184)

# Conflicts:
#	CHANGELOG.md
#	python/src/ccf/ledger.py
#	tests/e2e_operations.py
@eddyashton eddyashton added the backported This PR was successfully backported to LTS branch label Jun 3, 2025
eddyashton added a commit that referenced this pull request Jun 3, 2025
…aviour of writing to temporary uncommitted file and renaming (#7029) (#7034)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.x-todo PRs which should be backported to 5.x auto-backport Automatically backport this PR to LTS branch backported This PR was successfully backported to LTS branch run-long-test Run Long Test job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants