Skip to content

Commit

Permalink
Merge #31312
Browse files Browse the repository at this point in the history
31312: storage: move MergeQueueEnabled to storagebase r=jordanlewis a=jordanlewis

... to avoid dependency edge from sql to storage.

Updates #30001.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
  • Loading branch information
craig[bot] and jordanlewis committed Oct 13, 2018
2 parents 3e1c440 + 6bdcfd0 commit 3960772
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/sql/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/types"
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/storage/storagebase"
)

type splitNode struct {
Expand Down Expand Up @@ -106,7 +106,7 @@ func (n *splitNode) startExec(params runParams) error {
// because of gossip inconsistency, or it could change halfway through the
// SPLIT AT's execution. It is, however, likely to prevent user error and
// confusion in the common case.
if !n.force && storage.MergeQueueEnabled.Get(&params.p.ExecCfg().Settings.SV) {
if !n.force && storagebase.MergeQueueEnabled.Get(&params.p.ExecCfg().Settings.SV) {
return errors.New("splits would be immediately discarded by merge queue; " +
"disable the merge queue first by running 'SET CLUSTER SETTING kv.range_merge.queue_enabled = false'")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/client_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ func TestMergeQueue(t *testing.T) {
storeCfg.TestingKnobs.DisableSplitQueue = true
storeCfg.TestingKnobs.DisableScanner = true
sv := &storeCfg.Settings.SV
storage.MergeQueueEnabled.Override(sv, true)
storagebase.MergeQueueEnabled.Override(sv, true)
storage.MergeQueueInterval.Override(sv, 0) // process greedily
var mtc multiTestContext
mtc.storeConfig = &storeCfg
Expand Down
11 changes: 2 additions & 9 deletions pkg/storage/merge_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb"
"github.com/cockroachdb/cockroach/pkg/storage/storagebase"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
)
Expand All @@ -44,14 +45,6 @@ const (
mergeQueueConcurrency = 1
)

// MergeQueueEnabled is a setting that controls whether the merge queue is
// enabled.
var MergeQueueEnabled = settings.RegisterBoolSetting(
"kv.range_merge.queue_enabled",
"whether the automatic merge queue is enabled",
false,
)

// MergeQueueInterval is a setting that controls how often the merge queue waits
// between processing replicas.
var MergeQueueInterval = func() *settings.DurationSetting {
Expand Down Expand Up @@ -127,7 +120,7 @@ func newMergeQueue(store *Store, db *client.DB, gossip *gossip.Gossip) *mergeQue

func (mq *mergeQueue) enabled() bool {
st := mq.store.ClusterSettings()
return st.Version.IsMinSupported(cluster.VersionRangeMerges) && MergeQueueEnabled.Get(&st.SV)
return st.Version.IsMinSupported(cluster.VersionRangeMerges) && storagebase.MergeQueueEnabled.Get(&st.SV)
}

func (mq *mergeQueue) shouldQueue(
Expand Down
5 changes: 3 additions & 2 deletions pkg/storage/merge_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import (
"context"
"testing"

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/gogo/protobuf/proto"

"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb"
"github.com/cockroachdb/cockroach/pkg/storage/storagebase"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/stop"
Expand All @@ -39,7 +40,7 @@ func TestMergeQueueShouldQueue(t *testing.T) {
testCtx.Start(t, stopper)

mq := newMergeQueue(testCtx.store, testCtx.store.DB(), testCtx.gossip)
MergeQueueEnabled.Override(&testCtx.store.ClusterSettings().SV, true)
storagebase.MergeQueueEnabled.Override(&testCtx.store.ClusterSettings().SV, true)

tableKey := func(i uint32) []byte {
return keys.MakeTablePrefix(keys.MaxReservedDescID + i)
Expand Down
9 changes: 9 additions & 0 deletions pkg/storage/storagebase/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@ import (

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/storage/storagepb"
)

// MergeQueueEnabled is a setting that controls whether the merge queue is
// enabled.
var MergeQueueEnabled = settings.RegisterBoolSetting(
"kv.range_merge.queue_enabled",
"whether the automatic merge queue is enabled",
false,
)

// TxnCleanupThreshold is the threshold after which a transaction is
// considered abandoned and fit for removal, as measured by the
// maximum of its last heartbeat and timestamp. Abort spans for the
Expand Down

0 comments on commit 3960772

Please sign in to comment.