avoid data race read volume.IsEmpty (#4574)

* avoid data race read volume.IsEmpty

-   avoid phantom read isEmpty for onlyEmpty
-   use `v.DataBackend.GetStat()` in v.dataFileAccessLock scope

* add Destroy(onlyEmpty: true) test

* add Destroy(onlyEmpty: false) test

* remove unused `IsEmpty()`

* change literal `8` to `SuperBlockSize`
This commit is contained in:
柏杰
2023-06-15 05:39:58 +08:00
committed by GitHub
parent 1e22d5caf2
commit 0b0fb9b9e4
7 changed files with 164 additions and 18 deletions

View File

@@ -137,7 +137,7 @@ func runBackup(cmd *Command, args []string) bool {
if datSize > stats.TailOffset {
// remove the old data
v.Destroy()
v.Destroy(false)
// recreate an empty volume
v, err = storage.NewVolume(util.ResolvePath(*s.dir), util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, 0, 0)
if err != nil {