Skip to content

writing truncation log entry in case of truncation after failing a write#706

Merged
hg-ms merged 1 commit into
mainfrom
704-partial-single-channel-store-failure-leaves-storage-un-reopenable
Jun 12, 2026
Merged

writing truncation log entry in case of truncation after failing a write#706
hg-ms merged 1 commit into
mainfrom
704-partial-single-channel-store-failure-leaves-storage-un-reopenable

Conversation

@hg-ms

@hg-ms hg-ms commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Log a truncation entry when rolling back a partial store.

When one channel's write fails mid-store while a sibling channel already wrote its slice, the engine rolls back the successful channel by truncating its data file. Previously StorageFileManager.rollbackWrite truncated
the file but never recorded a matching truncation entry in the transaction log — so the store entry written earlier kept claiming the larger, pre-rollback length. On the next start, validateStorageDataFilesLength saw
a data file shorter than its logged length and threw StorageExceptionConsistency, leaving the storage permanently un-openable.

The fix makes rollbackWrite write a FILE_TRUNCATION transaction entry before truncating (mirroring handleLastFile), keeping the transaction log and the data file consistent. A totalLength() != size() guard ensures
only channels that actually wrote uncommitted data emit an entry. On restart, the recovery analysis resolves the store-then-truncate pair to the rolled-back length and reopens cleanly to the last consistent state —
the truncation case the transaction analysis was already designed to handle.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a recovery/consistency issue where a partial store rollback truncated a data file without writing a corresponding FILE_TRUNCATION transaction entry, allowing the transaction log to claim a larger length than the actual file and potentially preventing storage from reopening after restart.

Changes:

  • Add a guard in rollbackWrite() to only emit truncation behavior when needed.
  • Write a FILE_TRUNCATION transaction entry before truncating during rollback, mirroring handleLastFile() behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hg-ms hg-ms requested a review from fh-ms June 12, 2026 11:03
@hg-ms hg-ms merged commit 32a345e into main Jun 12, 2026
15 checks passed
@hg-ms hg-ms deleted the 704-partial-single-channel-store-failure-leaves-storage-un-reopenable branch June 12, 2026 11:27
@hg-ms

hg-ms commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

fixed #704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants