Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: RunValueGC #2037

Open
fehrnah opened this issue Dec 18, 2023 · 1 comment
Open

[BUG]: RunValueGC #2037

fehrnah opened this issue Dec 18, 2023 · 1 comment
Labels
kind/bug Something is broken.

Comments

@fehrnah
Copy link

fehrnah commented Dec 18, 2023

What version of Badger are you using?

github.com/dgraph-io/badger/v4 v4.2.0

What version of Go are you using?

go version go1.21.5 linux/amd64

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

Reproduced on multiple machines, including laptop and server.

What steps will reproduce the bug?

Re-write a single key multiple time with a big enough value.

Example code:

package main

import (
	"crypto/rand"
	"log"
	"log/slog"

	"github.com/dgraph-io/badger/v4"
)

func main() {
	dir := "/tmp/badger_test"

	slog.Warn("starting", slog.String("db_path", dir))
	db, err := badger.Open(badger.DefaultOptions(dir))
	if err != nil {
		log.Fatal(err)
	}

	data := make([]byte, 10*2<<20)
	for i := 0; i < 1000; i++ {
		slog.Info("starting iteration", slog.Int("iteration_number", i))
		err = db.Update(func(txn *badger.Txn) error {
			_, err := rand.Read(data)
			if err != nil {
				return err
			}

			return txn.Set([]byte("data"), data)
		})

		if err != nil {
			log.Fatal(err)
		}

		if i%100 == 0 {
			err = db.RunValueLogGC(0.5)
			if err != nil && err != badger.ErrNoRewrite {
				log.Fatal(err)
			}
		}
	}
}

Expected behavior and actual result.

Expected:
The size of the /tmp/badger_test folder to be bounded and not grow.

Actual:
The size of the /tmp/badger_test folder keeps growing.

After running the reproduction:

$ du -h  /tmp/badger_test 
20G     /tmp/badger_test

Additional information

No response

@fehrnah fehrnah added the kind/bug Something is broken. label Dec 18, 2023
@fehrnah
Copy link
Author

fehrnah commented Dec 18, 2023

Looks to be a duplicate of #2003.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken.
Development

No branches or pull requests

1 participant