mirror of https://github.com/etcd-io/bbolt.git
TestDB_Concurrent_WriteTo: copy option to fix data race
The test log: ================== WARNING: DATA RACE Write at 0x00c000388370 by goroutine 37: go.etcd.io/bbolt/internal/btesting.MustOpenDBWithOption() /home/runner/work/bbolt/bbolt/internal/btesting/btesting.go:52 +0x1c7 go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo.func1() /home/runner/work/bbolt/bbolt/db_test.go:685 +0x1f4 go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo·dwrap·18() /home/runner/work/bbolt/bbolt/db_test.go:714 +0x47 Previous write at 0x00c000388370 by goroutine 83: go.etcd.io/bbolt/internal/btesting.MustOpenDBWithOption() /home/runner/work/bbolt/bbolt/internal/btesting/btesting.go:52 +0x1c7 go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo.func1() /home/runner/work/bbolt/bbolt/db_test.go:685 +0x1f4 go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo·dwrap·18() /home/runner/work/bbolt/bbolt/db_test.go:714 +0x47 Goroutine 37 (running) created at: go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo() /home/runner/work/bbolt/bbolt/db_test.go:714 +0x724 testing.tRunner() /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x22f testing.(*T).Run·dwrap·21() /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1306 +0x47 Goroutine 83 (running) created at: go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo() /home/runner/work/bbolt/bbolt/db_test.go:714 +0x724 testing.tRunner() /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x22f testing.(*T).Run·dwrap·21() /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1306 +0x47 ================== Signed-off-by: Wei Fu <fuweid89@gmail.com>pull/373/head
parent
5104c82310
commit
4e98e8fb3c
|
@ -682,7 +682,9 @@ func TestDB_Concurrent_WriteTo(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
snap := btesting.MustOpenDBWithOption(t, f.Name(), o)
|
|
||||||
|
copyOpt := *o
|
||||||
|
snap := btesting.MustOpenDBWithOption(t, f.Name(), ©Opt)
|
||||||
defer snap.MustClose()
|
defer snap.MustClose()
|
||||||
snap.MustCheck()
|
snap.MustCheck()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue