diff --git a/src/meta/src/stream/scale.rs b/src/meta/src/stream/scale.rs index 6ecb061e509b..634cca76f0d7 100644 --- a/src/meta/src/stream/scale.rs +++ b/src/meta/src/stream/scale.rs @@ -163,7 +163,12 @@ impl From<&PbFragment> for CustomFragmentInfo { .first() .cloned() .expect("no actor in fragment"), - actors: fragment.actors.iter().map(CustomActorInfo::from).collect(), + actors: fragment + .actors + .iter() + .map(CustomActorInfo::from) + .sorted_by(|actor_a, actor_b| actor_a.actor_id.cmp(&actor_b.actor_id)) + .collect(), } } } @@ -275,8 +280,12 @@ pub fn rebalance_actor_vnode( .partition(|(actor_id, _)| actors_to_remove.contains(actor_id)); let order_by_bitmap_desc = - |(_, bitmap_a): &(ActorId, Bitmap), (_, bitmap_b): &(ActorId, Bitmap)| -> Ordering { - bitmap_a.count_ones().cmp(&bitmap_b.count_ones()).reverse() + |(id_a, bitmap_a): &(ActorId, Bitmap), (id_b, bitmap_b): &(ActorId, Bitmap)| -> Ordering { + bitmap_a + .count_ones() + .cmp(&bitmap_b.count_ones()) + .reverse() + .then(id_a.cmp(id_b)) }; let builder_from_bitmap = |bitmap: &Bitmap| -> BitmapBuilder {