未验证 提交 71d4a32c 编写于 作者: Y yah01 提交者: GitHub

Fix deadlock (#19340)

The IsParentDropped() acquires read lock of meta,
which leads to recursively acquire read lock
Signed-off-by: Nyah01 <yang.cen@zilliz.com>
Signed-off-by: Nyah01 <yang.cen@zilliz.com>
上级 72346f31
......@@ -236,9 +236,10 @@ func (t *compactionTrigger) handleGlobalSignal(signal *compactionSignal) {
return (signal.collectionID == 0 || segment.CollectionID == signal.collectionID) &&
isSegmentHealthy(segment) &&
isFlush(segment) &&
IsParentDropped(t.meta, segment) &&
IsParentDroppedUnsafe(t.meta, segment) &&
!segment.isCompacting // not compacting now
}) // m is list of chanPartSegments, which is channel-partition organized segments
for _, group := range m {
if !signal.isForce && t.compactionHandler.isFull() {
break
......
......@@ -186,9 +186,22 @@ func extractSegmentsWithVectorIndex(vecFieldID map[int64]int64, segentIndexInfo
return indexedSegments.Collect()
}
// IsParentDropped checks whether a segment exists,
// with acquiring read-lock of meta.
func IsParentDropped(meta *meta, segment *SegmentInfo) bool {
for _, from := range segment.CompactionFrom {
if meta.GetSegment(from) != nil {
if meta.GetSegmentUnsafe(from) != nil {
return false
}
}
return true
}
// IsParentDroppedUnsafe same as IsParentDropped,
// but not acquiring read-lock of meta.
func IsParentDroppedUnsafe(meta *meta, segment *SegmentInfo) bool {
for _, from := range segment.CompactionFrom {
if meta.segments.GetSegment(from) != nil {
return false
}
}
......
......@@ -46,6 +46,7 @@ class TestCompactionParams(TestcaseBase):
expected: Merge into one segment
"""
# init collection with one shard, insert into two segments
pytest.skip("DataCoord: for A, B -> C, will not compact segment C before A, B GCed, no method to check whether a segment is GCed")
collection_w = self.collection_insert_multi_segments_one_shard(prefix, nb_of_segment=tmp_nb)
# first compact two segments
......@@ -861,6 +862,7 @@ class TestCompactionOperation(TestcaseBase):
expected: Verify segments info
"""
# greater than auto-merge threshold 10
pytest.skip("DataCoord: for A, B -> C, will not compact segment C before A, B GCed, no method to check whether a segment is GCed")
num_of_segment = ct.compact_segment_num_threshold + 1
# create collection shard_num=1, insert 11 segments, each with one entity
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册