Program hangs after ErrNoRewrite

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

1.18

What operating system are you using?

Linux

What version of Badger are you using?

v3.2103.2

Does this issue reproduce with the latest master?

Not sure, I’m running latest release

What Badger options were set?

Default configuration

What did you do?

I have a program which is a plugin for another software which uses Badger as a DB for storing data. For garbage collection I run RunValueLogGC every 6 hours. This is the code that does it:

err := n.DB.db.RunValueLogGC(0.5)
if err != nil {
	n.Logf(Unusual, "GC report: %+v", err)
}

An user had a problem with the following log trace:

Sep 03 00:36:48 UNUSUAL db.go:158 GarbageCollect: GC report: Value log GC attempt didn't result in any cleanup 
Sep 03 00:36:48 UNUSUAL github.com/dgraph-io/badger/v3.init 
Sep 03 00:36:48 UNUSUAL /path/to/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/errors.go:67 
Sep 03 00:36:48 UNUSUAL runtime.doInit 
Sep 03 00:36:48 UNUSUAL /usr/local/go/src/runtime/proc.go:6222 
Sep 03 00:36:48 UNUSUAL runtime.doInit 
Sep 03 00:36:48 UNUSUAL /usr/local/go/src/runtime/proc.go:6199 
Sep 03 00:36:48 UNUSUAL runtime.doInit 
Sep 03 00:36:48 UNUSUAL /usr/local/go/src/runtime/proc.go:6199 
Sep 03 00:36:48 UNUSUAL runtime.main 
Sep 03 00:36:48 UNUSUAL /usr/local/go/src/runtime/proc.go:233 
Sep 03 00:36:48 UNUSUAL runtime.goexit 
Sep 03 00:36:48 UNUSUAL /usr/local/go/src/runtime/asm_amd64.s:1571

After this, the software did not work as expected anymore.

What did you expect to see?

I would have expected badger to return ErrNoRewrite and go on normally

What did you see instead?

The software did no work as expected after ErrNoRewrite.

A possible problem would be that during garbage collection, it’s possible for the software to asynchronously access the database for reading and writing. Can this be a problem? Do I have to lock access to the db when garbage collecting?