From 9e3a591bda9a79464f8449cf06c0813eec0447ed Mon Sep 17 00:00:00 2001 From: congqixia Date: Mon, 10 Jul 2023 18:58:28 +0800 Subject: [PATCH] Fix segment released early in case of balancing (#25453) Signed-off-by: Congqi Xia --- internal/querynodev2/delegator/distribution.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/querynodev2/delegator/distribution.go b/internal/querynodev2/delegator/distribution.go index 73a0f96b96..c8ca791fb6 100644 --- a/internal/querynodev2/delegator/distribution.go +++ b/internal/querynodev2/delegator/distribution.go @@ -253,11 +253,9 @@ func (d *distribution) RemoveDistributions(sealedSegments []SegmentEntry, growin d.mut.Lock() defer d.mut.Unlock() - changed := false for _, sealed := range sealedSegments { if d.offlines.Contain(sealed.SegmentID) { d.offlines.Remove(sealed.SegmentID) - changed = true } entry, ok := d.sealedSegments[sealed.SegmentID] if !ok { @@ -265,7 +263,6 @@ func (d *distribution) RemoveDistributions(sealedSegments []SegmentEntry, growin } if entry.NodeID == sealed.NodeID || sealed.NodeID == wildcardNodeID { delete(d.sealedSegments, sealed.SegmentID) - changed = true } } @@ -276,14 +273,10 @@ func (d *distribution) RemoveDistributions(sealedSegments []SegmentEntry, growin } delete(d.growingSegments, growing.SegmentID) - changed = true - } - - if !changed { - // no change made, return closed signal channel - return getClosedCh() } + // wait previous read even not distribution changed + // in case of segment balance caused segment lost track return d.genSnapshot() }