Skip to content

Commit

Permalink
Use ts as msgID for request
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Zhang <[email protected]>
  • Loading branch information
xiaocai2333 committed Nov 2, 2024
1 parent b792b19 commit 358929d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
8 changes: 2 additions & 6 deletions internal/proxy/task_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,14 @@ func (queue *baseTaskQueue) Enqueue(t task) error {
var id UniqueID
if t.CanSkipAllocTimestamp() {
ts = tsoutil.ComposeTS(time.Now().UnixMilli(), 0)
id, err = globalMetaCache.AllocID(t.TraceCtx())
if err != nil {
return err
}
} else {
ts, err = queue.tsoAllocatorIns.AllocOne(t.TraceCtx())
if err != nil {
return err
}
// we always use same msg id and ts for now.
id = UniqueID(ts)
}
// we always use same msg id and ts for now.
id = UniqueID(ts)
t.SetTs(ts)
t.SetID(id)

Expand Down
18 changes: 0 additions & 18 deletions internal/proxy/task_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ func TestTaskScheduler_SkipAllocTimestamp(t *testing.T) {
collID: collID,
consistencyLevel: commonpb.ConsistencyLevel_Eventually,
}, nil)
mockMetaCache.EXPECT().AllocID(mock.Anything).Return(1, nil).Twice()

t.Run("query", func(t *testing.T) {
qt := &queryTask{
Expand Down Expand Up @@ -658,21 +657,4 @@ func TestTaskScheduler_SkipAllocTimestamp(t *testing.T) {
err := queue.Enqueue(st)
assert.NoError(t, err)
})

mockMetaCache.EXPECT().AllocID(mock.Anything).Return(0, fmt.Errorf("mock error")).Once()
t.Run("failed", func(t *testing.T) {
st := &searchTask{
SearchRequest: &internalpb.SearchRequest{
Base: &commonpb.MsgBase{},
},
request: &milvuspb.SearchRequest{
DbName: dbName,
CollectionName: collName,
UseDefaultConsistency: true,
},
}

err := queue.Enqueue(st)
assert.Error(t, err)
})
}

0 comments on commit 358929d

Please sign in to comment.