Skip to content

Commit

Permalink
storage: add env var for aggressive consistency checks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tbg committed Sep 21, 2018
1 parent f7abfb3 commit ef1f5b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/storage/consistency_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/merge_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/replicate_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ef1f5b0

Please sign in to comment.