Skip to content
Snippets Groups Projects
Commit ca3187d1 authored by Bingyi Sun 【孙秉义】's avatar Bingyi Sun 【孙秉义】 Committed by yefu.chen
Browse files

Fix data race in datanode tests


Signed-off-by: default avatarsunby <bingyi.sun@zilliz.com>
parent 972dad4d
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment