forked from milvus-io/milvus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make qcv2 observer dispatcher execute exactly once (milvus-io#28472
) See also milvus-io#28466 In `taskDispatcher.schedule`, same task may be resubmitted if the previous round did not finish In this case, TaskObserver.check may set current target by mistake, which may cause the random search/query failure Signed-off-by: Congqi Xia <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package observers | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/milvus-io/milvus/pkg/util/paramtable" | ||
"github.com/milvus-io/milvus/pkg/util/typeutil" | ||
) | ||
|
||
type taskDispatcherSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func (s *taskDispatcherSuite) SetupSuite() { | ||
paramtable.Get().Init(paramtable.NewBaseTable()) | ||
} | ||
|
||
func (s *taskDispatcherSuite) TestMultipleSubmit() { | ||
var wg sync.WaitGroup | ||
wg.Add(6) | ||
|
||
set := typeutil.NewConcurrentSet[int64]() | ||
dispatcher := newTaskDispatcher(func(ctx context.Context, key int64) { | ||
defer wg.Done() | ||
set.Insert(key) | ||
time.Sleep(time.Second) | ||
}) | ||
dispatcher.Start() | ||
|
||
dispatcher.AddTask(1, 2, 3, 4, 5) | ||
dispatcher.AddTask(2, 3, 4, 5, 6) | ||
wg.Wait() | ||
|
||
s.ElementsMatch([]int64{1, 2, 3, 4, 5, 6}, set.Collect()) | ||
|
||
dispatcher.Stop() | ||
} | ||
|
||
func TestTaskDispatcher(t *testing.T) { | ||
suite.Run(t, new(taskDispatcherSuite)) | ||
} |