未验证 提交 74ae8d39 编写于 作者: C congqixia 提交者: GitHub

Fix nil segment caused panic in handleSignal (#13990)

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 d6e26859
......@@ -269,6 +269,10 @@ func (t *compactionTrigger) handleSignal(signal *compactionSignal) {
}
segment := t.meta.GetSegment(signal.segmentID)
if segment == nil {
log.Warn("segment in compaction signal not found in meta", zap.Int64("segmentID", signal.segmentID))
return
}
singleCompactionPlan, err := t.singleCompaction(segment, signal.isForce, signal)
if err != nil {
log.Warn("failed to do single compaction", zap.Int64("segmentID", segment.ID), zap.Error(err))
......
......@@ -1103,3 +1103,14 @@ func Test_newCompactionTrigger(t *testing.T) {
})
}
}
func Test_handleSignal(t *testing.T) {
got := newCompactionTrigger(&meta{segments: NewSegmentsInfo()}, &compactionPlanHandler{}, newMockAllocator())
signal := &compactionSignal{
segmentID: 1,
}
assert.NotPanics(t, func() {
got.handleSignal(signal)
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册