Skip to content

Commit c626983

Browse files
tbgandy-kimball
authored andcommitted
storage: add env var for aggressive consistency checks
We saw a consistency failure in cockroachdb#29252 that would've been much more useful had it occurred close to the time around which the inconsistency must have been introduced. Instead of leaving it to chance, add a switch that runs aggressive checks in (roach) tests that want them such as the clearrange test. Release note: None
1 parent 922422c commit c626983

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

pkg/storage/consistency_queue.go

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/gossip"
2323
"github.com/cockroachdb/cockroach/pkg/roachpb"
2424
"github.com/cockroachdb/cockroach/pkg/settings"
25+
"github.com/cockroachdb/cockroach/pkg/util/envutil"
2526
"github.com/cockroachdb/cockroach/pkg/util/grpcutil"
2627
"github.com/cockroachdb/cockroach/pkg/util/hlc"
2728
"github.com/cockroachdb/cockroach/pkg/util/log"
@@ -33,6 +34,8 @@ var consistencyCheckInterval = settings.RegisterNonNegativeDurationSetting(
3334
24*time.Hour,
3435
)
3536

37+
var testingAggressiveConsistencyChecks = envutil.EnvOrDefaultBool("COCKROACH_CONSISTENCY_AGGRESSIVE", false)
38+
3639
type consistencyQueue struct {
3740
*baseQueue
3841
interval func() time.Duration

pkg/storage/merge_queue.go

+5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ func (mq *mergeQueue) process(
273273
// as purgatory-worthy.
274274
return rangeMergePurgatoryError{err}
275275
}
276+
if testingAggressiveConsistencyChecks {
277+
if err := mq.store.consistencyQueue.process(ctx, lhsRepl, sysCfg); err != nil {
278+
log.Warning(ctx, err)
279+
}
280+
}
276281
return nil
277282
}
278283

pkg/storage/replicate_queue.go

+5
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ func (rq *replicateQueue) process(
265265
// Enqueue this replica again to see if there are more changes to be made.
266266
rq.MaybeAdd(repl, rq.store.Clock().Now())
267267
}
268+
if testingAggressiveConsistencyChecks {
269+
if err := rq.store.consistencyQueue.process(ctx, repl, sysCfg); err != nil {
270+
log.Warning(ctx, err)
271+
}
272+
}
268273
return nil
269274
}
270275
return errors.Errorf("failed to replicate after %d retries", retryOpts.MaxRetries)

0 commit comments

Comments
 (0)