Skip to content

fix: prevent data loss in raid failsafe transition and import#2181

Open
mrv777 wants to merge 2 commits into
getumbrel:masterfrom
mrv777:fix/raid-migration-data-loss
Open

fix: prevent data loss in raid failsafe transition and import#2181
mrv777 wants to merge 2 commits into
getumbrel:masterfrom
mrv777:fix/raid-migration-data-loss

Conversation

@mrv777

@mrv777 mrv777 commented Jun 30, 2026

Copy link
Copy Markdown

Found these while reviewing the storage code. All three can lose user data.

raid failsafe transition (boot script)
The final zfs send | zfs receive before the pool rename had no error check, and the function runs under || true so set -e doesn't catch it. If that sync failed, we'd rename the migration pool into place anyway (missing the last delta) and umbreld would then destroy the original pool. Now we only rename if the sync succeeded, otherwise we bail and boot back into the original pool.

raid completeFailsafeTransition
It destroyed the previous (backup) pool after only checking that the previous pool existed, never that the new main pool actually came up. Added a check to bail if the main pool isn't there.

data import migration
activateImportedDataDirectory moves import -> temp -> data dir in two steps, guarded only by import existing. If we got killed between the moves, the imported data was orphaned in the temp dir forever and we'd boot with the un-imported data. Now it resumes the second move if the temp dir is there.

Tested: typecheck passes, boot script passes bash -n. The raid transition path needs a VM to test properly, not done here.

mrv777 added 2 commits June 30, 2026 12:04
- raid: don't rename pools if the final zfs sync fails. otherwise we promote the migration pool without the last delta and then destroy the original copy.
- raid: bail out of completeFailsafeTransition if the new main pool isn't there, so we don't wipe the previous pool.
- migration: resume the import move if we were killed mid-move so the imported data doesn't get orphaned in the temp dir.
if the final sync fails we leave the @migration-final snapshot behind. destroy any stale one before recreating so retries are clean and we don't rely on errexit being suppressed in this function.
@mrv777
mrv777 marked this pull request as ready for review June 30, 2026 17:28
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.

1 participant