Skip to content

Commit

Permalink
internal/cache: include countCold and sizeCold in runHandCold stack t…
Browse files Browse the repository at this point in the history
…races

Add countCold and sizeCold as parameters to runHandCold so that stack
traces from any future cockroachdb/cockroach#70154 reproductions will
include their values.
  • Loading branch information
jbowens committed Sep 22, 2021
1 parent d4f91a7 commit add3d11
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions internal/cache/clockpro.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,21 @@ func (c *shard) metaEvict(e *entry) {

func (c *shard) evict() {
for c.targetSize() <= c.sizeHot+c.sizeCold && c.handCold != nil {
c.runHandCold()
c.runHandCold(c.countCold, c.sizeCold)
}
}

func (c *shard) runHandCold() {
func (c *shard) runHandCold(countColdDebug, sizeColdDebug int64) {
// countColdDebug and sizeColdDebug should equal c.countCold and
// c.sizeCold. They're parameters only to aid in debugging of
// cockroachdb/cockroach#70154. Since they're parameters, their
// arguments will appear within stack traces should we encounter
// a reproduction.
if c.countCold != countColdDebug || c.sizeCold != sizeColdDebug {
panic(fmt.Sprintf("runHandCold: cold count and size are %d, %d, arguments are %d and %d",
c.countCold, c.sizeCold, countColdDebug, sizeColdDebug))
}

e := c.handCold
if e.ptype == etCold {
if atomic.LoadInt32(&e.referenced) == 1 {
Expand Down Expand Up @@ -503,7 +513,7 @@ func (c *shard) runHandTest() {
panic(fmt.Sprintf("pebble: mismatch %d cold size, %d cold count", c.sizeCold, c.countCold))
}

c.runHandCold()
c.runHandCold(c.countCold, c.sizeCold)
if c.handTest == nil {
return
}
Expand Down

0 comments on commit add3d11

Please sign in to comment.