diff --git a/pkg/storage/consistency_queue.go b/pkg/storage/consistency_queue.go index bbcf04ab4430..d3884551b2da 100644 --- a/pkg/storage/consistency_queue.go +++ b/pkg/storage/consistency_queue.go @@ -22,6 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/gossip" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/settings" + "github.com/cockroachdb/cockroach/pkg/util/envutil" "github.com/cockroachdb/cockroach/pkg/util/grpcutil" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -33,6 +34,8 @@ var consistencyCheckInterval = settings.RegisterNonNegativeDurationSetting( 24*time.Hour, ) +var testingAggressiveConsistencyChecks = envutil.EnvOrDefaultBool("COCKROACH_CONSISTENCY_AGGRESSIVE", false) + type consistencyQueue struct { *baseQueue interval func() time.Duration diff --git a/pkg/storage/merge_queue.go b/pkg/storage/merge_queue.go index 1b06fd995034..7001d1da0ae5 100644 --- a/pkg/storage/merge_queue.go +++ b/pkg/storage/merge_queue.go @@ -269,6 +269,11 @@ func (mq *mergeQueue) process( // as purgatory-worthy. return rangeMergePurgatoryError{err} } + if testingAggressiveConsistencyChecks { + if err := mq.store.consistencyQueue.process(ctx, lhsRepl, sysCfg); err != nil { + log.Warning(ctx, err) + } + } return nil } diff --git a/pkg/storage/replicate_queue.go b/pkg/storage/replicate_queue.go index ca4df3dd537f..659859a4150e 100644 --- a/pkg/storage/replicate_queue.go +++ b/pkg/storage/replicate_queue.go @@ -265,6 +265,11 @@ func (rq *replicateQueue) process( // Enqueue this replica again to see if there are more changes to be made. rq.MaybeAdd(repl, rq.store.Clock().Now()) } + if testingAggressiveConsistencyChecks { + if err := rq.store.consistencyQueue.process(ctx, repl, sysCfg); err != nil { + log.Warning(ctx, err) + } + } return nil } return errors.Errorf("failed to replicate after %d retries", retryOpts.MaxRetries)