flush_manager_test.go 16.8 KB
Newer Older
C
congqixia 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package datanode

import (
20
	"context"
C
congqixia 已提交
21
	"crypto/rand"
22
	"errors"
C
congqixia 已提交
23 24
	"sync"
	"testing"
25
	"time"
C
congqixia 已提交
26

S
SimFG 已提交
27 28
	"github.com/milvus-io/milvus-proto/go-api/commonpb"
	"github.com/milvus-io/milvus-proto/go-api/schemapb"
29
	"github.com/milvus-io/milvus/internal/proto/datapb"
C
congqixia 已提交
30
	"github.com/milvus-io/milvus/internal/proto/internalpb"
31
	"github.com/milvus-io/milvus/internal/storage"
32
	"github.com/milvus-io/milvus/internal/util/retry"
C
congqixia 已提交
33 34 35 36 37
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"go.uber.org/atomic"
)

38 39
var flushTestDir = "/tmp/milvus_test/flush"

C
congqixia 已提交
40 41 42 43 44 45 46 47 48 49
type emptyFlushTask struct{}

func (t *emptyFlushTask) flushInsertData() error {
	return nil
}

func (t *emptyFlushTask) flushDeleteData() error {
	return nil
}

50 51 52 53 54 55 56 57 58 59
type errFlushTask struct{}

func (t *errFlushTask) flushInsertData() error {
	return errors.New("mocked error")
}

func (t *errFlushTask) flushDeleteData() error {
	return errors.New("mocked error")
}

C
congqixia 已提交
60 61 62 63 64 65
func TestOrderFlushQueue_Execute(t *testing.T) {
	counter := atomic.Int64{}
	finish := sync.WaitGroup{}

	size := 1000
	finish.Add(size)
66
	q := newOrderFlushQueue(1, func(*segmentFlushPack) {
C
congqixia 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
		counter.Inc()
		finish.Done()
	})

	q.init()
	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	wg := sync.WaitGroup{}
	wg.Add(2 * size)
	for i := 0; i < size; i++ {
		go func(id []byte) {
83
			q.enqueueDelFlush(&emptyFlushTask{}, &DelDataBuf{}, &internalpb.MsgPosition{
C
congqixia 已提交
84 85 86 87 88
				MsgID: id,
			})
			wg.Done()
		}(ids[i])
		go func(id []byte) {
89
			q.enqueueInsertFlush(&emptyFlushTask{}, map[UniqueID]*datapb.Binlog{}, map[UniqueID]*datapb.Binlog{}, false, false, &internalpb.MsgPosition{
C
congqixia 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
				MsgID: id,
			})
			wg.Done()
		}(ids[i])
	}
	wg.Wait()
	finish.Wait()

	assert.EqualValues(t, size, counter.Load())
}
func TestOrderFlushQueue_Order(t *testing.T) {
	counter := atomic.Int64{}
	finish := sync.WaitGroup{}

	size := 1000
	finish.Add(size)
	resultList := make([][]byte, 0, size)
107
	q := newOrderFlushQueue(1, func(pack *segmentFlushPack) {
C
congqixia 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
		counter.Inc()
		resultList = append(resultList, pack.pos.MsgID)
		finish.Done()
	})

	q.init()
	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	wg := sync.WaitGroup{}
	wg.Add(size)
	for i := 0; i < size; i++ {
124
		q.enqueueDelFlush(&emptyFlushTask{}, &DelDataBuf{}, &internalpb.MsgPosition{
C
congqixia 已提交
125 126
			MsgID: ids[i],
		})
127
		q.enqueueInsertFlush(&emptyFlushTask{}, map[UniqueID]*datapb.Binlog{}, map[UniqueID]*datapb.Binlog{}, false, false, &internalpb.MsgPosition{
C
congqixia 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
			MsgID: ids[i],
		})
		wg.Done()
	}
	wg.Wait()
	finish.Wait()

	assert.EqualValues(t, size, counter.Load())

	require.Equal(t, size, len(resultList))
	for i := 0; i < size; i++ {
		assert.EqualValues(t, ids[i], resultList[i])
	}
}

143 144 145 146 147 148
func newTestChannel() *ChannelMeta {
	return &ChannelMeta{
		segments: make(map[UniqueID]*Segment),
	}
}

C
congqixia 已提交
149
func TestRendezvousFlushManager(t *testing.T) {
150 151
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
152
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
153
	defer cm.RemoveWithPrefix(ctx, "")
C
congqixia 已提交
154 155 156 157 158

	size := 1000
	var counter atomic.Int64
	finish := sync.WaitGroup{}
	finish.Add(size)
159
	m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
C
congqixia 已提交
160 161
		counter.Inc()
		finish.Done()
162
	}, emptyFlushAndDropFunc)
C
congqixia 已提交
163 164 165 166 167 168 169 170 171 172 173 174 175 176

	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	wg := sync.WaitGroup{}
	wg.Add(size)
	for i := 0; i < size; i++ {
		m.flushDelData(nil, 1, &internalpb.MsgPosition{
			MsgID: ids[i],
		})
177
		m.flushBufferData(nil, 1, true, false, &internalpb.MsgPosition{
C
congqixia 已提交
178 179 180 181 182 183 184 185
			MsgID: ids[i],
		})
		wg.Done()
	}
	wg.Wait()
	finish.Wait()

	assert.EqualValues(t, size, counter.Load())
186 187 188
}

func TestRendezvousFlushManager_Inject(t *testing.T) {
189 190
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
191
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
192
	defer cm.RemoveWithPrefix(ctx, "")
193 194 195 196 197

	size := 1000
	var counter atomic.Int64
	finish := sync.WaitGroup{}
	finish.Add(size)
198 199
	var packMut sync.Mutex
	packs := make([]*segmentFlushPack, 0, size+3)
200
	m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
201
		packMut.Lock()
202
		packs = append(packs, pack)
203
		packMut.Unlock()
204 205
		counter.Inc()
		finish.Done()
206
	}, emptyFlushAndDropFunc)
207

208 209 210 211
	ti := newTaskInjection(1, func(*segmentFlushPack) {})
	m.injectFlush(ti, 1)
	<-ti.injected
	ti.injectDone(true)
212 213 214 215 216 217 218 219 220 221 222 223 224 225

	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	wg := sync.WaitGroup{}
	wg.Add(size)
	for i := 0; i < size; i++ {
		m.flushDelData(nil, 1, &internalpb.MsgPosition{
			MsgID: ids[i],
		})
226
		m.flushBufferData(nil, 1, true, false, &internalpb.MsgPosition{
227 228 229 230 231 232 233 234 235
			MsgID: ids[i],
		})
		wg.Done()
	}
	wg.Wait()
	finish.Wait()

	assert.EqualValues(t, size, counter.Load())

236
	finish.Add(2)
237 238
	id := make([]byte, 10)
	rand.Read(id)
239 240
	id2 := make([]byte, 10)
	rand.Read(id2)
241
	m.flushBufferData(nil, 2, true, false, &internalpb.MsgPosition{
242 243
		MsgID: id,
	})
244
	m.flushBufferData(nil, 3, true, false, &internalpb.MsgPosition{
245 246
		MsgID: id2,
	})
247

248 249 250 251
	ti = newTaskInjection(2, func(pack *segmentFlushPack) {
		pack.segmentID = 4
	})
	m.injectFlush(ti, 2, 3)
252 253 254 255

	m.flushDelData(nil, 2, &internalpb.MsgPosition{
		MsgID: id,
	})
256 257 258
	m.flushDelData(nil, 3, &internalpb.MsgPosition{
		MsgID: id2,
	})
259 260
	<-ti.Injected()
	ti.injectDone(true)
261 262

	finish.Wait()
263 264
	assert.EqualValues(t, size+2, counter.Load())
	assert.EqualValues(t, 4, packs[size].segmentID)
265 266 267

	finish.Add(1)
	rand.Read(id)
268

269
	m.flushBufferData(nil, 2, false, false, &internalpb.MsgPosition{
270 271
		MsgID: id,
	})
272 273 274 275 276 277 278 279 280
	ti = newTaskInjection(1, func(pack *segmentFlushPack) {
		pack.segmentID = 5
	})
	go func() {
		<-ti.injected
		ti.injectDone(false) // inject fail, segment id shall not be changed to 5
	}()
	m.injectFlush(ti, 2)

281 282 283 284
	m.flushDelData(nil, 2, &internalpb.MsgPosition{
		MsgID: id,
	})
	finish.Wait()
285 286
	assert.EqualValues(t, size+3, counter.Load())
	assert.EqualValues(t, 4, packs[size+1].segmentID)
C
congqixia 已提交
287 288

}
289 290

func TestRendezvousFlushManager_getSegmentMeta(t *testing.T) {
291
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
292 293 294
	channel := newTestChannel()
	channel.collSchema = &schemapb.CollectionSchema{}
	fm := NewRendezvousFlushManager(NewAllocatorFactory(), cm, channel, func(*segmentFlushPack) {
295
	}, emptyFlushAndDropFunc)
296 297 298 299 300

	// non exists segment
	_, _, _, err := fm.getSegmentMeta(-1, &internalpb.MsgPosition{})
	assert.Error(t, err)

301 302 303 304
	seg0 := Segment{segmentID: -1}
	seg1 := Segment{segmentID: 1}
	seg0.setType(datapb.SegmentType_New)
	seg1.setType(datapb.SegmentType_New)
305

306 307 308 309 310 311 312 313 314
	channel.segments[-1] = &seg0
	channel.segments[1] = &seg1

	// // injected get part/coll id error
	// _, _, _, err = fm.getSegmentMeta(-1, &internalpb.MsgPosition{})
	// assert.Error(t, err)
	// // injected get schema  error
	// _, _, _, err = fm.getSegmentMeta(1, &internalpb.MsgPosition{})
	// assert.Error(t, err)
315
}
316

317
func TestRendezvousFlushManager_waitForAllFlushQueue(t *testing.T) {
318
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
319 320 321 322 323

	size := 1000
	var counter atomic.Int64
	var finish sync.WaitGroup
	finish.Add(size)
324
	m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
		counter.Inc()
		finish.Done()
	}, emptyFlushAndDropFunc)

	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	for i := 0; i < size; i++ {
		m.flushDelData(nil, 1, &internalpb.MsgPosition{
			MsgID: ids[i],
		})
	}

	var finished bool
	var mut sync.RWMutex
	signal := make(chan struct{})

	go func() {
		m.waitForAllFlushQueue()
		mut.Lock()
		finished = true
		mut.Unlock()
		close(signal)
	}()

	mut.RLock()
	assert.False(t, finished)
	mut.RUnlock()

	for i := 0; i < size/2; i++ {
359
		m.flushBufferData(nil, 1, true, false, &internalpb.MsgPosition{
360 361 362 363 364 365 366 367 368
			MsgID: ids[i],
		})
	}

	mut.RLock()
	assert.False(t, finished)
	mut.RUnlock()

	for i := size / 2; i < size; i++ {
369
		m.flushBufferData(nil, 1, true, false, &internalpb.MsgPosition{
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
			MsgID: ids[i],
		})
	}

	timeout := time.NewTimer(time.Second)
	select {
	case <-timeout.C:
		t.FailNow()
	case <-signal:
	}

	mut.RLock()
	assert.True(t, finished)
	mut.RUnlock()
}

func TestRendezvousFlushManager_dropMode(t *testing.T) {
387
	t.Run("test drop mode", func(t *testing.T) {
388
		cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
389 390 391 392 393

		var mut sync.Mutex
		var result []*segmentFlushPack
		signal := make(chan struct{})

394
		m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
395 396 397 398 399 400
		}, func(packs []*segmentFlushPack) {
			mut.Lock()
			result = packs
			mut.Unlock()
			close(signal)
		})
401

402
		halfMsgID := []byte{1, 1, 1}
403
		m.flushBufferData(nil, -1, true, false, &internalpb.MsgPosition{
404 405
			MsgID: halfMsgID,
		})
406

407 408 409 410 411
		m.startDropping()
		// half normal, half drop mode, should not appear in final packs
		m.flushDelData(nil, -1, &internalpb.MsgPosition{
			MsgID: halfMsgID,
		})
412

413 414 415
		target := make(map[int64]struct{})
		for i := 1; i < 11; i++ {
			target[int64(i)] = struct{}{}
416
			m.flushBufferData(nil, int64(i), true, false, &internalpb.MsgPosition{
417 418 419 420 421 422
				MsgID: []byte{1},
			})
			m.flushDelData(nil, int64(i), &internalpb.MsgPosition{
				MsgID: []byte{1},
			})
		}
423

424 425 426 427 428 429 430 431 432 433 434 435 436 437
		m.notifyAllFlushed()

		<-signal
		mut.Lock()
		defer mut.Unlock()

		output := make(map[int64]struct{})
		for _, pack := range result {
			assert.NotEqual(t, -1, pack.segmentID)
			output[pack.segmentID] = struct{}{}
			_, has := target[pack.segmentID]
			assert.True(t, has)
		}
		assert.Equal(t, len(target), len(output))
438
	})
439
	t.Run("test drop mode with injection", func(t *testing.T) {
440
		cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
441 442 443 444 445

		var mut sync.Mutex
		var result []*segmentFlushPack
		signal := make(chan struct{})

446
		m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
447 448 449 450 451 452
		}, func(packs []*segmentFlushPack) {
			mut.Lock()
			result = packs
			mut.Unlock()
			close(signal)
		})
453

454
		halfMsgID := []byte{1, 1, 1}
455
		m.flushBufferData(nil, -1, true, false, &internalpb.MsgPosition{
456
			MsgID: halfMsgID,
457
		})
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472

		injFunc := func(pack *segmentFlushPack) {
			pack.segmentID = 100
		}
		for i := 1; i < 11; i++ {
			it := newTaskInjection(1, injFunc)
			m.injectFlush(it, int64(i))
			<-it.Injected()
			it.injectDone(true)
		}

		m.startDropping()
		// half normal, half drop mode, should not appear in final packs
		m.flushDelData(nil, -1, &internalpb.MsgPosition{
			MsgID: halfMsgID,
473 474
		})

475
		for i := 1; i < 11; i++ {
476
			m.flushBufferData(nil, int64(i), true, false, &internalpb.MsgPosition{
477 478 479 480 481 482 483 484 485 486 487 488
				MsgID: []byte{1},
			})
			m.flushDelData(nil, int64(i), &internalpb.MsgPosition{
				MsgID: []byte{1},
			})
		}

		m.notifyAllFlushed()

		<-signal
		mut.Lock()
		defer mut.Unlock()
489

490 491 492 493 494
		for _, pack := range result {
			assert.NotEqual(t, -1, pack.segmentID)
			assert.Equal(t, int64(100), pack.segmentID)
		}
	})
495 496 497

}

C
congqixia 已提交
498
func TestRendezvousFlushManager_close(t *testing.T) {
499
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
C
congqixia 已提交
500 501 502 503 504

	size := 1000
	var counter atomic.Int64
	finish := sync.WaitGroup{}
	finish.Add(size)
505
	m := NewRendezvousFlushManager(&allocator{}, cm, newTestChannel(), func(pack *segmentFlushPack) {
C
congqixia 已提交
506 507
		counter.Inc()
		finish.Done()
508
	}, emptyFlushAndDropFunc)
C
congqixia 已提交
509 510 511 512 513 514 515 516 517 518 519 520 521 522

	ids := make([][]byte, 0, size)
	for i := 0; i < size; i++ {
		id := make([]byte, 10)
		rand.Read(id)
		ids = append(ids, id)
	}

	wg := sync.WaitGroup{}
	wg.Add(size)
	for i := 0; i < size; i++ {
		m.flushDelData(nil, 1, &internalpb.MsgPosition{
			MsgID: ids[i],
		})
523
		m.flushBufferData(nil, 1, true, false, &internalpb.MsgPosition{
C
congqixia 已提交
524 525 526 527 528 529 530 531 532 533 534
			MsgID: ids[i],
		})
		wg.Done()
	}
	wg.Wait()
	finish.Wait()
	m.close()

	assert.EqualValues(t, size, counter.Load())
}

535
func TestFlushNotifyFunc(t *testing.T) {
X
xige-16 已提交
536 537 538
	rcf := &RootCoordFactory{
		pkType: schemapb.DataType_Int64,
	}
539
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
540

541
	channel := newChannel("channel", 1, nil, rcf, cm)
542 543 544 545 546

	dataCoord := &DataCoordFactory{}
	flushingCache := newCache()
	dsService := &dataSyncService{
		collectionID:     1,
547
		channel:          channel,
548 549 550 551 552 553 554 555
		dataCoord:        dataCoord,
		flushingSegCache: flushingCache,
	}
	notifyFunc := flushNotifyFunc(dsService, retry.Attempts(1))

	t.Run("normal run", func(t *testing.T) {
		assert.NotPanics(t, func() {
			notifyFunc(&segmentFlushPack{
556 557 558
				insertLogs: map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/id"}},
				statsLogs:  map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/id-stats"}},
				deltaLogs:  []*datapb.Binlog{{LogPath: "/dev/test/del"}},
559 560 561 562 563 564 565 566 567 568 569 570 571
				flushed:    true,
			})
		})
	})

	t.Run("pack has error", func(t *testing.T) {
		assert.Panics(t, func() {
			notifyFunc(&segmentFlushPack{
				err: errors.New("mocked pack error"),
			})
		})
	})

572
	t.Run("datacoord save fails", func(t *testing.T) {
573
		dataCoord.SaveBinlogPathStatus = commonpb.ErrorCode_UnexpectedError
574 575 576 577 578
		assert.Panics(t, func() {
			notifyFunc(&segmentFlushPack{})
		})
	})

579 580 581 582 583 584 585
	t.Run("normal segment not found", func(t *testing.T) {
		dataCoord.SaveBinlogPathStatus = commonpb.ErrorCode_SegmentNotFound
		assert.Panics(t, func() {
			notifyFunc(&segmentFlushPack{flushed: true})
		})
	})

586 587 588 589 590 591 592 593 594
	// issue https://github.com/milvus-io/milvus/issues/17097
	// meta error, datanode shall not panic, just drop the virtual channel
	t.Run("datacoord found meta error", func(t *testing.T) {
		dataCoord.SaveBinlogPathStatus = commonpb.ErrorCode_MetaFailed
		assert.NotPanics(t, func() {
			notifyFunc(&segmentFlushPack{})
		})
	})

595 596 597 598 599 600 601
	t.Run("datacoord call error", func(t *testing.T) {
		dataCoord.SaveBinlogPathError = true
		assert.Panics(t, func() {
			notifyFunc(&segmentFlushPack{})
		})
	})
}
602 603

func TestDropVirtualChannelFunc(t *testing.T) {
X
xige-16 已提交
604 605 606
	rcf := &RootCoordFactory{
		pkType: schemapb.DataType_Int64,
	}
607
	vchanName := "vchan_01"
X
xige-16 已提交
608

609
	cm := storage.NewLocalChunkManager(storage.RootPath(flushTestDir))
610
	channel := newChannel(vchanName, 1, nil, rcf, cm)
611 612 613 614 615

	dataCoord := &DataCoordFactory{}
	flushingCache := newCache()
	dsService := &dataSyncService{
		collectionID:     1,
616
		channel:          channel,
617 618
		dataCoord:        dataCoord,
		flushingSegCache: flushingCache,
619
		vchannelName:     vchanName,
620 621 622
	}
	dropFunc := dropVirtualChannelFunc(dsService, retry.Attempts(1))
	t.Run("normal run", func(t *testing.T) {
623
		channel.addSegment(
624 625 626 627 628
			addSegmentReq{
				segType:     datapb.SegmentType_New,
				segID:       2,
				collID:      1,
				partitionID: 10,
629 630
				startPos: &internalpb.MsgPosition{
					ChannelName: vchanName,
631 632 633
					MsgID:       []byte{1, 2, 3},
					Timestamp:   10,
				}, endPos: nil})
634 635 636 637
		assert.NotPanics(t, func() {
			dropFunc([]*segmentFlushPack{
				{
					segmentID:  1,
638 639 640
					insertLogs: map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/id"}},
					statsLogs:  map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/id-stats"}},
					deltaLogs:  []*datapb.Binlog{{LogPath: "/dev/test/del"}},
641
					pos: &internalpb.MsgPosition{
642
						ChannelName: vchanName,
643 644 645 646 647 648
						MsgID:       []byte{1, 2, 3},
						Timestamp:   10,
					},
				},
				{
					segmentID:  1,
649 650 651
					insertLogs: map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/idi_2"}},
					statsLogs:  map[UniqueID]*datapb.Binlog{1: {LogPath: "/dev/test/id-stats-2"}},
					deltaLogs:  []*datapb.Binlog{{LogPath: "/dev/test/del-2"}},
652
					pos: &internalpb.MsgPosition{
653
						ChannelName: vchanName,
654 655 656 657 658 659 660 661
						MsgID:       []byte{1, 2, 3},
						Timestamp:   30,
					},
				},
			})
		})
	})
	t.Run("datacoord drop fails", func(t *testing.T) {
662
		dataCoord.DropVirtualChannelStatus = commonpb.ErrorCode_UnexpectedError
663 664 665 666 667 668 669
		assert.Panics(t, func() {
			dropFunc(nil)
		})
	})

	t.Run("datacoord call error", func(t *testing.T) {

670
		dataCoord.DropVirtualChannelStatus = commonpb.ErrorCode_UnexpectedError
671 672 673 674 675 676
		dataCoord.DropVirtualChannelError = true
		assert.Panics(t, func() {
			dropFunc(nil)
		})
	})

677 678 679 680 681 682 683 684 685 686
	// issue https://github.com/milvus-io/milvus/issues/17097
	// meta error, datanode shall not panic, just drop the virtual channel
	t.Run("datacoord found meta error", func(t *testing.T) {
		dataCoord.DropVirtualChannelStatus = commonpb.ErrorCode_MetaFailed
		dataCoord.DropVirtualChannelError = false
		assert.NotPanics(t, func() {
			dropFunc(nil)
		})
	})

687
}