提交 ca3187d1 编写于 作者: S sunby 提交者: yefu.chen

Fix data race in datanode tests

Signed-off-by: Nsunby <bingyi.sun@zilliz.com>
上级 972dad4d
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册