Skip to content

Commit

Permalink
pkg/auth/badgerauth: fix infinite loop in gcValueLog
Browse files Browse the repository at this point in the history
652b63d introduced an infinite loop in gcValueLog. This change fixes it
by adding a necessary additional condition to make sure the loop always
exits.

Change-Id: I98d41e72eb899062775f9e46b7c68e3743e5c169
  • Loading branch information
amwolff committed Jul 6, 2022
1 parent 652b63d commit 1e85c31
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/auth/badgerauth/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func OpenDB(log *zap.Logger, config Config) (*DB, error) {
func (db *DB) gcValueLog(ctx context.Context) (err error) {
defer mon.Task()(&ctx)(nil)

gcLoop:
for err == nil {
gcFinished := mon.TaskNamed("gc")(&ctx)
select {
Expand All @@ -128,7 +129,9 @@ func (db *DB) gcValueLog(ctx context.Context) (err error) {
default:
// Run GC and optionally silence ErrNoRewrite errors:
if err = db.db.RunValueLogGC(.5); errs.Is(err, badger.ErrNoRewrite) {
gcFinished(nil)
err = nil
break gcLoop
}
}
gcFinished(&err)
Expand Down

0 comments on commit 1e85c31

Please sign in to comment.