fix: Make SyncManager callback func ignore nil error (#32891)

introduced by #32865

sync manager callback handler panicked when error is nil

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-05-09 18:03:31 +08:00 committed by GitHub
parent 54a51b1236
commit 77fa615772
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -134,6 +134,9 @@ func (mgr *syncManager) safeSubmitTask(task Task) *conc.Future[struct{}] {
func (mgr *syncManager) submit(key int64, task Task) *conc.Future[struct{}] { func (mgr *syncManager) submit(key int64, task Task) *conc.Future[struct{}] {
handler := func(err error) error { handler := func(err error) error {
if err == nil {
return nil
}
// unexpected error // unexpected error
if !errors.Is(err, errTargetSegmentNotMatch) { if !errors.Is(err, errTargetSegmentNotMatch) {
task.HandleError(err) task.HandleError(err)

View File

@ -318,7 +318,6 @@ func (s *SyncManagerSuite) TestTargetUpdated() {
task.EXPECT().CalcTargetSegment().Return(1001, nil).Once() task.EXPECT().CalcTargetSegment().Return(1001, nil).Once()
task.EXPECT().Run().Return(errTargetSegmentNotMatch).Once() task.EXPECT().Run().Return(errTargetSegmentNotMatch).Once()
task.EXPECT().Run().Return(nil).Once() task.EXPECT().Run().Return(nil).Once()
task.EXPECT().HandleError(mock.Anything)
f := manager.SyncData(context.Background(), task) f := manager.SyncData(context.Background(), task)
_, err = f.Await() _, err = f.Await()