feat(syncoid): Add "createtxg" property to `getsnaps`

The `getsnaps` subroutine now retrieves the "createtxg" property of the
snapshot.

This is necessary to support the fix for
https://github.com/jimsalterjrs/sanoid/issues/815 (Syncoid: Data loss
because getoldestsnapshot() might not choose the first snapshot).
This commit is contained in:
Nick Liu 2023-04-25 14:01:54 -05:00
parent e301b5b153
commit 8fabaae5b8
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
1 changed files with 10 additions and 4 deletions

14
syncoid
View File

@ -1816,8 +1816,8 @@ sub getsnaps {
}
my $getsnapcmd = $use_fallback
? "$rhost $mysudocmd $zfscmd get -Hpd 1 type,guid,creation $fsescaped"
: "$rhost $mysudocmd $zfscmd get -Hpd 1 -t snapshot guid,creation $fsescaped";
? "$rhost $mysudocmd $zfscmd get -Hpd 1 all $fsescaped"
: "$rhost $mysudocmd $zfscmd get -Hpd 1 -t snapshot all $fsescaped";
if ($debug) {
$getsnapcmd = "$getsnapcmd |";
@ -1841,8 +1841,13 @@ sub getsnaps {
for my $line (@rawsnaps) {
chomp $line;
my ($dataset, $property, $value) = split /\t/, $line;
my ($fs, $snap) = split /@/, $dataset;
if (!snapisincluded($snap)) { next; }
die "CRITICAL ERROR: Unexpected line format in $line" unless defined $value;
my (undef, $snap) = split /@/, $dataset;
die "CRITICAL ERROR: Unexpected dataset format in $line" unless $snap;
if (!snapisincluded($snap)) { next; }
$snap_data{$snap}{$property} = $value;
# the accuracy of the creation timestamp is only for a second, but
@ -1868,6 +1873,7 @@ sub getsnaps {
for my $snap (keys %snap_data) {
if (!$use_fallback || $snap_data{$snap}{'type'} eq 'snapshot') {
$snaps{$type}{$snap}{'guid'} = $snap_data{$snap}{'guid'};
$snaps{$type}{$snap}{'createtxg'} = $snap_data{$snap}{'createtxg'};
$snaps{$type}{$snap}{'creation'} = $snap_data{$snap}{'creation'};
}
}