mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
test concurrent value imports, fix race
This commit is contained in:
parent
9fda9cf6a3
commit
4420d72196
2 changed files with 23 additions and 0 deletions
|
|
@ -1785,7 +1785,9 @@ func (f *fragment) importValue(columnIDs, values []uint64, bitDepth uint, clear
|
|||
for i := uint(0); i < bitDepth+1; i++ {
|
||||
rowSet[uint64(i)] = struct{}{}
|
||||
}
|
||||
f.mu.Lock()
|
||||
err := f.importPositions(toSet, toClear, rowSet)
|
||||
f.mu.Unlock()
|
||||
return errors.Wrap(err, "importing positions")
|
||||
}
|
||||
err := f.snapshot()
|
||||
|
|
|
|||
|
|
@ -3024,3 +3024,24 @@ func TestSmallImportRestart(t *testing.T) {
|
|||
t.Errorf("row 1 should be [1], but got %v", r1)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportValueConcurrent(t *testing.T) {
|
||||
f := mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, "none")
|
||||
eg := &errgroup.Group{}
|
||||
for i := 0; i < 4; i++ {
|
||||
i := i
|
||||
eg.Go(func() error {
|
||||
for j := uint64(0); j < 10; j++ {
|
||||
err := f.importValue([]uint64{j}, []uint64{uint64(rand.Int63n(1000))}, 10, i%2 == 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
err := eg.Wait()
|
||||
if err != nil {
|
||||
t.Fatalf("concurrently importing values: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue