Skip to content

Commit

Permalink
kvnemesis: ignore SysBytes:{,-}10 MVCC stats discrepancy
Browse files Browse the repository at this point in the history
We started ignoring these in 398dfc7. However, that commit was
effectively reverted when we addressed #93896 in 2d855d3. However, like
2d855d3 notes in its description, this was best effort. As such, this
can still cause test flakes (e.g. #131187).

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

Epic: none

Release note: None
  • Loading branch information
arulajmani committed Sep 26, 2024
1 parent 83e8534 commit f746509
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 f746509

Please sign in to comment.