+ my (@old_shard, $over_chg);
+
+ # Sort shards highest-to-lowest, since ->xdb_shards_flat
+ # determines the number of shards to load based on the max;
+ # and we'd rather xdb_shards_flat to momentarily fail rather
+ # than load out-of-date shards
+ my @order = sort {
+ my ($x) = ($a =~ m!/([0-9]+)/*\z!);
+ my ($y) = ($b =~ m!/([0-9]+)/*\z!);
+ ($y // -1) <=> ($x // -1) # we may have non-shards
+ } keys %$tmp;
+
+ my ($dname) = ($order[0] =~ m!(.*/)[^/]+/*\z!);
+ my $mode = (stat($dname))[2];
+ for my $old (@order) {