mirror of https://github.com/milvus-io/milvus.git
Fix data race in datanode tests
Signed-off-by: sunby <bingyi.sun@zilliz.com>pull/4973/head^2
parent
972dad4d8e
commit
ca3187d173
|
@ -8,6 +8,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -384,6 +385,7 @@ func (df *DataFactory) GetMsgStreamInsertMsgs(n int) (inMsgs []*msgstream.Insert
|
|||
}
|
||||
|
||||
type AllocatorFactory struct {
|
||||
sync.Mutex
|
||||
r *rand.Rand
|
||||
}
|
||||
|
||||
|
@ -395,7 +397,9 @@ func NewAllocatorFactory(id ...UniqueID) *AllocatorFactory {
|
|||
return f
|
||||
}
|
||||
|
||||
func (alloc AllocatorFactory) allocID() (UniqueID, error) {
|
||||
func (alloc *AllocatorFactory) allocID() (UniqueID, error) {
|
||||
alloc.Lock()
|
||||
defer alloc.Unlock()
|
||||
return alloc.r.Int63n(1000000), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestDataSyncService_Start(t *testing.T) {
|
|||
"receiveBufSize": 1024,
|
||||
"pulsarBufSize": 1024}
|
||||
err := msFactory.SetParams(m)
|
||||
sync := newDataSyncService(ctx, flushChan, replica, allocFactory, msFactory)
|
||||
sync := newDataSyncService(ctx, flushChan, replica, &allocFactory, msFactory)
|
||||
sync.replica.addCollection(collMeta.ID, collMeta.Schema)
|
||||
sync.init()
|
||||
go sync.start()
|
||||
|
|
Loading…
Reference in New Issue