Skip to content
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

fix(syncoid): regather $snaps on --delete-target-snapshots flag #903

Conversation

spicyFajitas
Copy link

Issue

I've noticed that during Syncoid runs when using the --delete-target-snapshots and --no-sync-snap flags, there are issues with zfs rolling back snapshots during a sync.

The sync workflow looks something like this:

  • Initial start
    • Source: snap1, snap2
    • Target:
  • Sync snapshots to Target, take new snapshot on Source, delete snapshot on Source that isn't newest
    • Source: snap1, snap3
    • Target: snap1, snap2
  • Error occurs here when trying to run a subsequent sync as the %snaps are cached from before the rollback, but during the sync the snapshots are rolled back to the latest common and then %snaps contains snapshots to be deleted that no longer exist

Sync Outputs

### initial sync
root@target ~
 # syncoid root@source:source/ubuntu target/ubuntu --delete-target-snapshots --no-sync-snap
NEWEST SNAPSHOT: snapshot-snap2
Removing target/ubuntu because no matching snapshots were found
NEWEST SNAPSHOT: snapshot-snap2
INFO: Sending oldest full snapshot source/ubuntu@snapshot-snap0 (~ 1.0 GB) to new target filesystem:
1.05GiB 0:00:08 [ 132MiB/s] [=========================================================] 103%
INFO: Updating new target filesystem with incremental target/ubuntu@snapshot-snap0 ... snapshot-snap2 (~ 3.1 MB):
3.15MiB 0:00:00 [11.5MiB/s] [=========================================================] 102%
### problematic sync
root@target ~
 # syncoid root@source:source/ubuntu target/ubuntu --delete-target-snapshots --no-sync-snap
NEWEST SNAPSHOT: snapshot-snap3
Sending incremental source/ubuntu@snapshot-snap1 ... snapshot-snap3 (~ 14.3 MB):
15.1MiB 0:00:00 [ 120MiB/s] [=========================================================] 105%
 zfs destroy 'target/ubuntu'@snapshot-snap2 failed: could not find any snapshots to destroy; check snapshot names.
root@target ~

Proposed Solution

I found the section where %snaps is being set and copied it to the --delete-target-snapshots section, but I could also make that snippet a subroutine and call it in the original location as well as --delete-target-snapshots section. Mainly wanted to leave that to the maintainer(s) to decide

@spicyFajitas spicyFajitas marked this pull request as draft April 1, 2024 18:04
@spicyFajitas spicyFajitas force-pushed the regather_snapshots--delete-target-snaps_task branch from 5797463 to f893729 Compare April 1, 2024 18:13
@spicyFajitas spicyFajitas marked this pull request as ready for review April 1, 2024 18:17
@phreaker0 phreaker0 self-requested a review April 5, 2024 12:55
Copy link
Collaborator

@phreaker0 phreaker0 left a comment

Choose a reason for hiding this comment

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

this look good, thx!

@jimsalterjrs jimsalterjrs merged commit d800e5e into jimsalterjrs:master Apr 22, 2024
@spicyFajitas spicyFajitas deleted the regather_snapshots--delete-target-snaps_task branch April 23, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants