From 77fa615772fe8f0adaf3f2815245fc941ab72523 Mon Sep 17 00:00:00 2001 From: congqixia Date: Thu, 9 May 2024 18:03:31 +0800 Subject: [PATCH] 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 --- internal/datanode/syncmgr/sync_manager.go | 3 +++ internal/datanode/syncmgr/sync_manager_test.go | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/datanode/syncmgr/sync_manager.go b/internal/datanode/syncmgr/sync_manager.go index ebd3a224ef..1f4534c52f 100644 --- a/internal/datanode/syncmgr/sync_manager.go +++ b/internal/datanode/syncmgr/sync_manager.go @@ -134,6 +134,9 @@ func (mgr *syncManager) safeSubmitTask(task Task) *conc.Future[struct{}] { func (mgr *syncManager) submit(key int64, task Task) *conc.Future[struct{}] { handler := func(err error) error { + if err == nil { + return nil + } // unexpected error if !errors.Is(err, errTargetSegmentNotMatch) { task.HandleError(err) diff --git a/internal/datanode/syncmgr/sync_manager_test.go b/internal/datanode/syncmgr/sync_manager_test.go index cf9001500b..6f12a98df4 100644 --- a/internal/datanode/syncmgr/sync_manager_test.go +++ b/internal/datanode/syncmgr/sync_manager_test.go @@ -318,7 +318,6 @@ func (s *SyncManagerSuite) TestTargetUpdated() { task.EXPECT().CalcTargetSegment().Return(1001, nil).Once() task.EXPECT().Run().Return(errTargetSegmentNotMatch).Once() task.EXPECT().Run().Return(nil).Once() - task.EXPECT().HandleError(mock.Anything) f := manager.SyncData(context.Background(), task) _, err = f.Await()