diff --git a/internal/datanode/syncmgr/sync_manager.go b/internal/datanode/syncmgr/sync_manager.go index 3c1896400fb1a..84915f4575797 100644 --- a/internal/datanode/syncmgr/sync_manager.go +++ b/internal/datanode/syncmgr/sync_manager.go @@ -47,6 +47,9 @@ type SyncMeta struct { type SyncManager interface { // SyncData is the method to submit sync task. SyncData(ctx context.Context, task Task, callbacks ...func(error) error) (*conc.Future[struct{}], error) + + // Close waits for the task to finish and then shuts down the sync manager. + Close() error } type syncManager struct { diff --git a/internal/datanode/syncmgr/sync_manager_test.go b/internal/datanode/syncmgr/sync_manager_test.go index d2908b923e844..919ec39dad129 100644 --- a/internal/datanode/syncmgr/sync_manager_test.go +++ b/internal/datanode/syncmgr/sync_manager_test.go @@ -285,7 +285,8 @@ func (s *SyncManagerSuite) TestUnexpectedError() { task.EXPECT().Run().Return(merr.WrapErrServiceInternal("mocked")).Once() task.EXPECT().HandleError(mock.Anything) - f, _ := manager.SyncData(context.Background(), task) + f, err := manager.SyncData(context.Background(), task) + s.NoError(err) _, err = f.Await() s.Error(err) } @@ -300,7 +301,9 @@ func (s *SyncManagerSuite) TestTargetUpdateSameID() { task.EXPECT().Run().Return(errors.New("mock err")).Once() task.EXPECT().HandleError(mock.Anything) - f, _ := manager.SyncData(context.Background(), task) + f, err := manager.SyncData(context.Background(), task) + s.NoError(err) + _, err = f.Await() s.Error(err) }