Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
131446: kvnemesis: ignore SysBytes:{,-}10 MVCC stats discrepancy r=pav-kv a=arulajmani

We started ignoring these in 398dfc7. However, that commit was effectively reverted when we addressed cockroachdb#93896 in 2d855d3. However, like 2d855d3 notes in its description, this was best effort. As such, this can still cause test flakes (e.g. cockroachdb#131187).

This patch effectively resurrects 398dfc7, but also additionally quietens `SysBytes:-10` failure mdoes.

Epic: none

Release note: None

Co-authored-by: Arul Ajmani <arulajmani@gmail.com>
  • Loading branch information
craig[bot] and arulajmani committed Sep 27, 2024
2 parents 497c316 + c8e59fb commit 0ea0320
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/kv/kvnemesis/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"context"
gosql "database/sql"
"fmt"
"regexp"
"time"

"github.com/cockroachdb/cockroach-go/v2/crdb"
Expand Down Expand Up @@ -68,6 +69,23 @@ func (e *Env) CheckConsistency(ctx context.Context, span roachpb.Span) []error {
if err := rows.Scan(&rangeID, &key, &status, &detail); err != nil {
return []error{err}
}
// NB: There's a known issue that can result in a 10-byte discrepancy in
// SysBytes. See:
// https://github.com/cockroachdb/cockroach/issues/93896
//
// This isn't critical, so we ignore such discrepancies.
if status == kvpb.CheckConsistencyResponse_RANGE_CONSISTENT_STATS_INCORRECT.String() {
m := regexp.MustCompile(`.*\ndelta \(stats-computed\): \{(.*)\}`).FindStringSubmatch(detail)
if len(m) > 1 {
delta := m[1]
// Strip out LastUpdateNanos and all zero-valued fields.
delta = regexp.MustCompile(`LastUpdateNanos:\d+`).ReplaceAllString(delta, "")
delta = regexp.MustCompile(`\S+:0\b`).ReplaceAllString(delta, "")
if regexp.MustCompile(`^\s*SysBytes:-?10\s*$`).MatchString(delta) {
continue
}
}
}
switch status {
case kvpb.CheckConsistencyResponse_RANGE_INDETERMINATE.String():
// Can't do anything, so let it slide.
Expand Down

0 comments on commit 0ea0320

Please sign in to comment.