From f74650988dc2f8284b233426610ac140f3fdbbae Mon Sep 17 00:00:00 2001 From: Arul Ajmani Date: Thu, 26 Sep 2024 17:25:30 +0000 Subject: [PATCH] kvnemesis: ignore SysBytes:{,-}10 MVCC stats discrepancy 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 --- pkg/kv/kvnemesis/env.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/kv/kvnemesis/env.go b/pkg/kv/kvnemesis/env.go index 9aa39d77f935..1a2afa5da786 100644 --- a/pkg/kv/kvnemesis/env.go +++ b/pkg/kv/kvnemesis/env.go @@ -14,6 +14,7 @@ import ( "context" gosql "database/sql" "fmt" + "regexp" "time" "github.com/cockroachdb/cockroach-go/v2/crdb" @@ -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.