Unable to delete the mem file when closing the db under windows 10 20h2

What version of Go are you using (go version)?

$ go version
go version go1.15.6 windows/amd64

What operating system are you using?

Windows 10 Pro for Workstations
20H2 19042.746 Windows Feature Experience Pack 120.2212.551.0

What version of Badger are you using?

BadgerDB v3.2011.0

Does this issue reproduce with the latest master?

Yes

Steps to Reproduce the issue

package main

import (
	"fmt"
	"github.com/dgraph-io/badger/v3"
	"path/filepath"
)

func main() {
	b, err := badger.Open(badger.DefaultOptions(filepath.Join(".", "test")))
	if err != nil {
		panic(err)
	}
	defer b.Close()
	fmt.Println("Ok")
}

What Badger options were set?

Default

What did you do?

go run .

Run the above command two times

What did you expect to see?

The db is closed successfully and could be reopen without any problem.

What did you see instead?

Just censored my username.

> go run .
badger 2021/01/19 19:18:47 INFO: All 0 tables opened in 0s
badger 2021/01/19 19:18:47 INFO: Discard stats nextEmptySlot: 0
badger 2021/01/19 19:18:47 INFO: Set nextTxnTs to 0
Ok
badger 2021/01/19 19:18:47 INFO: Lifetime L0 stalled for: 0s
badger 2021/01/19 19:18:47 ERROR: while deleting file: test/00001.mem, err: remove test/00001.mem: The process cannot access the file because it is being used by another process.
badger 2021/01/19 19:18:47 INFO:
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 5 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 6 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level Done

> go run .
panic: while opening memtables error: while opening fid: 1 error: Create a new file
github.com/dgraph-io/ristretto/z.init
        C:/Users/<my username>/go/pkg/mod/github.com/dgraph-io/ristretto@v0.0.4-0.20201224172411-e860a6c48e8a/z/file.go:36
runtime.doInit
        c:/go/src/runtime/proc.go:5652
runtime.doInit
        c:/go/src/runtime/proc.go:5647
runtime.doInit
        c:/go/src/runtime/proc.go:5647
runtime.doInit
        c:/go/src/runtime/proc.go:5647
runtime.main
        c:/go/src/runtime/proc.go:191
runtime.goexit
        c:/go/src/runtime/asm_amd64.s:1374

goroutine 1 [running]:
main.main()
        C:/Users/<my username>/dev/test-badger/main.go:12 +0x229
exit status 2

Hey @lonelyevil, can you please check on the latest master, or v3.2011.1? We pushed out few windows fixes recently.

1 Like

Fixed. Thanks.

1 Like