Repository navigation
Fix incorrect resharding transfer fraction for points to transfer - #6259
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
| // - shards: 3 -> 4 | ||
| // points: 33/33/33 -> 25/25/25/25 | ||
| // transfer fraction of each shard: 1/4/3 = 0.083 | ||
| Ordering::Less => (1.0 / to as f32) / (from as f32), |
There was a problem hiding this comment.
The final / from here was wrong. It adjusted the factor from shard level to collection level, which was not correct.
4f2e008 to
8fc4417
Compare
Co-authored-by: Kumar Shivendu <[email protected]>
5f56cc3 to
fe11d80
Compare
KShivendu
left a comment
There was a problem hiding this comment.
thanks for the quick update!
ffuugoo
left a comment
There was a problem hiding this comment.
LGTM, but do we even need this method on HashRing? Can't we just derive this from resharding state? It's literally just points_in_shard / new_shard_count, no point in calculating f32 multiplier.
Yes. With the previous (wrong 🤡) implementation it was a bit more complex, and the plan was to use it in two places. But now that it's simpler I'll move it directly into the call site instead. 👍 |
) * Fix incorrect resharding transfer fraction for points to transfer * Explicitly handle case where from and to are the same * Update lib/collection/src/hash_ring.rs Co-authored-by: Kumar Shivendu <[email protected]> * Move point fraction calculation right into the call site * Don't use intermediate f64 --------- Co-authored-by: Kumar Shivendu <[email protected]>
Fixes incorrect implementation in #6084.
The function to calculate the fraction of points transferred during a resharding transfer was incorrect. For resharding up it gave us the wrong result.
For resharding up, the returned fraction was for the total number of points in the collection, not a fraction for the number of points in the current shard like the function describes.
Long story short, this fixed the fraction calculation. The documentation with examples has been updated as well.
In practice this fixes our point count estimate in shard transfers. It's not critical, but helpful to do proper transfer estimations.
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --all --all-featurescommand?