Skip to content

Commit

Permalink
fix: Sort by actor_id in CustomFragmentInfo and rebalance_actor_vnode…
Browse files Browse the repository at this point in the history
… for consistent ordering (#18317)

Signed-off-by: Shanicky Chen <[email protected]>
  • Loading branch information
shanicky authored Aug 29, 2024
1 parent edb1493 commit 655ce2a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/meta/src/stream/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 655ce2a

Please sign in to comment.