Skip to content

Commit

Permalink
internal/cache: mark panic messages as redaction-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowens committed Aug 7, 2023
1 parent 40d3f41 commit af8c5f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/cache/refcnt_normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package cache
import (
"fmt"
"sync/atomic"

"github.com/cockroachdb/redact"
)

// refcnt provides an atomic reference count. This version is used when the
Expand All @@ -31,14 +33,14 @@ func (v *refcnt) refs() int32 {
func (v *refcnt) acquire() {
switch v := v.val.Add(1); {
case v <= 1:
panic(fmt.Sprintf("pebble: inconsistent reference count: %d", v))
panic(redact.Safe(fmt.Sprintf("pebble: inconsistent reference count: %d", v)))
}
}

func (v *refcnt) release() bool {
switch v := v.val.Add(-1); {
case v < 0:
panic(fmt.Sprintf("pebble: inconsistent reference count: %d", v))
panic(redact.Safe(fmt.Sprintf("pebble: inconsistent reference count: %d", v)))
case v == 0:
return true
default:
Expand Down

0 comments on commit af8c5f2

Please sign in to comment.