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

d.Backup() is 100% read IO ! #2069

Closed
rockit-ba opened this issue Jul 5, 2024 · 2 comments
Closed

d.Backup() is 100% read IO ! #2069

rockit-ba opened this issue Jul 5, 2024 · 2 comments
Labels
kind/question Something requiring a response Stale

Comments

@rockit-ba
Copy link

Question.

When I use d.Backup() to backup, read IO will be 100% immediately. It is almost inevitable. When I frequently insert and delete key-value pairs, I backup every 100,000 or so times.

It is very likely to happen when I use d.Backup() for the second or third time. My machine is 4 cores and 8 GB. At that time, the CPU was very low, but the read IO was 100%. I had to restart the server because it could not do anything.

image image image

code:

func (d *badgerPersist) RaftBackup(sink raft.SnapshotSink) error {
	var number uint64
	if _, err := os.Stat(filename); os.IsNotExist(err) {
		number = 0
	} else {
		data, err := os.ReadFile(filename)
		if err != nil {
			return err
		}
		number, err = strconv.ParseUint(string(data), 10, 64)
		if err != nil {
			return err
		}
	}

	log.Info("start to backup data", "lastVersion", number)
	newLastVersion, err := d.Backup(bufio.NewWriter(sink), number)
	if err != nil {
		return err
	}
	log.Info("finish to backup data", "lastVersion", newLastVersion)
	err = os.WriteFile(filename, []byte(strconv.FormatUint(newLastVersion, 10)), 0644)
	if err != nil {
		return err
	}
	return nil
}
@rockit-ba rockit-ba added the kind/question Something requiring a response label Jul 5, 2024
@rockit-ba
Copy link
Author

this is my config

func initOps() badger.Options {
	return badger.DefaultOptions(storagePath).
		WithNumGoroutines(runtime.NumCPU() * 2)
}

and i do GC

func dBGc(db *badger.DB) {
	for range gcTicker.C {
	again:
		err := db.RunValueLogGC(0.5)
		if err == nil {
			log.Info("badger gc success")
			goto again
		}
	}
}

Copy link

github-actions bot commented Jan 2, 2025

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.

@github-actions github-actions bot added the Stale label Jan 2, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Something requiring a response Stale
Development

No branches or pull requests

1 participant