Skip to content

Commit

Permalink
pkg/auth/badgerauth: add more granular reporting to gcValueLog
Browse files Browse the repository at this point in the history
This change will make it easier to observe individual value log garbage
collection run times and errors.

Change-Id: I5fdf7fa7bca6860cf6c7265aad5630e82e9f6134
  • Loading branch information
amwolff committed Jul 5, 2022
1 parent 731a53b commit a297560
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/auth/badgerauth/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ func OpenDB(log *zap.Logger, config Config) (*DB, error) {
return db, nil
}

// gcValueLog garbage collects value log. It always returns a nil error.
func (db *DB) gcValueLog(ctx context.Context) (err error) {
defer mon.Task()(&ctx)(&err)
defer mon.Task()(&ctx)(nil)

for err == nil {
gcFinished := mon.TaskNamed("gc")(&ctx)
select {
case <-ctx.Done():
err = ctx.Err()
default:
err = db.db.RunValueLogGC(0.5)
}
gcFinished(&err)
}
db.log.Info("value log garbage collection finished", zap.Error(err))
return nil
Expand Down

0 comments on commit a297560

Please sign in to comment.