]> git.proxmox.com Git - pve-guest-common.git/blobdiff - src/PVE/ReplicationState.pm
ReplicationState: deterministically order replication jobs
[pve-guest-common.git] / src / PVE / ReplicationState.pm
index 8eebb426414aceac68ce7a0dbc530df2ccd461cb..16b3d900425efc0aa4b0b1b46ae8cc7c5adf0253 100644 (file)
@@ -318,11 +318,10 @@ sub get_next_job {
        my $jobb = $jobs->{$b};
        my $sa =  $joba->{state};
        my $sb =  $jobb->{state};
-       my $res = $sa->{last_iteration} <=> $sb->{last_iteration};
-       return $res if $res != 0;
-       $res = $joba->{next_sync} <=> $jobb->{next_sync};
-       return $res if $res != 0;
-       return  $joba->{guest} <=> $jobb->{guest};
+       return $sa->{last_iteration} <=> $sb->{last_iteration} ||
+           $joba->{next_sync} <=> $jobb->{next_sync} ||
+           $joba->{guest} <=> $jobb->{guest} ||
+           $a cmp $b;
     };
 
     foreach my $jobid (sort $sort_func keys %$jobs) {