The comparator used to sort the scrub targets wasn't transitive, which
can lead to undefined behavior (and likely - to a crash of the sort
algorithm in some implementations). That - due to the clause comparing
the two targets of the same PG.
This commit fixes the comparator. The sorted queue is no longer
guaranteed to have a ripe deep target before the corresponding
shallow one, which is less than optimal - but it won't crash.
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
if (auto cmp = r.urgency <=> l.urgency; cmp != 0) {
return cmp;
}
- // if we are comparing the two targets of the same PG, once both are
- // ripe - the 'deep' scrub is considered 'higher' than the 'shallow' one.
- if (l.pgid == r.pgid && r.level < l.level) {
- return std::weak_ordering::less;
- }
// the 'utime_t' operator<=> is 'partial_ordering', it seems.
if (auto cmp = std::weak_order(
double(l.schedule.scheduled_at), double(r.schedule.scheduled_at));