Skip to content

Commit

Permalink
all: Revert #39722
Browse files Browse the repository at this point in the history
This reverts commit 0b0c71f, reversing
changes made to 9b36103.

Reverting "config,sqlbase: move computation of splits for SQL tables to
sqlbase". It seems to have caused TestInitialPartitioning and
TestRepartitioning to timeout often when run under testrace on TC (only
when the build runs on the master branch and these tests are run in
conjunction with all the other packages). I don't know what's wrong yet.

Fixes #41812
Fixes #41821
Fixes #41825
Fixes #41831
Fixes #41835
Fixes #41843
Fixes #41846
Fixes #41850
Fixes #41862
Fixes #41874
Fixes #41879

Fixes #41652
Fixes #41813
Fixes #41822
Fixes #41826
Fixes #41832
Fixes #41836
Fixes #41844
Fixes #41847
Fixes #41851
Fixes #41868
Fixes #41875

Release note: None
  • Loading branch information
andreimatei committed Oct 23, 2019
1 parent 242b6a5 commit 0cf7360
Show file tree
Hide file tree
Showing 122 changed files with 1,518 additions and 1,724 deletions.
4 changes: 2 additions & 2 deletions pkg/acceptance/cluster/dockercluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logflags"
Expand Down Expand Up @@ -66,7 +66,7 @@ const CockroachBinaryInContainer = "/cockroach/cockroach"
var cockroachImage = flag.String("i", defaultImage, "the docker image to run")
var cockroachEntry = flag.String("e", "", "the entry point for the image")
var waitOnStop = flag.Bool("w", false, "wait for the user to interrupt before tearing down the cluster")
var maxRangeBytes = *zonepb.DefaultZoneConfig().RangeMaxBytes
var maxRangeBytes = *config.DefaultZoneConfig().RangeMaxBytes

// CockroachBinary is the path to the host-side binary to use.
var CockroachBinary = flag.String("b", func() string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/acceptance/localcluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/rpc"
"github.com/cockroachdb/cockroach/pkg/security"
Expand Down Expand Up @@ -370,7 +370,7 @@ func (c *Cluster) isReplicated() (bool, string) {

// UpdateZoneConfig updates the default zone config for the cluster.
func (c *Cluster) UpdateZoneConfig(rangeMinBytes, rangeMaxBytes int64) {
zone := zonepb.DefaultZoneConfig()
zone := config.DefaultZoneConfig()
zone.RangeMinBytes = proto.Int64(rangeMinBytes)
zone.RangeMaxBytes = proto.Int64(rangeMaxBytes)

Expand Down
3 changes: 1 addition & 2 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
_ "github.com/cockroachdb/cockroach/pkg/ccl/partitionccl"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl/sampledataccl"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/internal/client"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
Expand Down Expand Up @@ -1000,7 +999,7 @@ func TestBackupRestoreControlJob(t *testing.T) {
t.Fatal(err)
}
last := uint32(v.ValueInt())
zoneConfig := zonepb.DefaultZoneConfig()
zoneConfig := config.DefaultZoneConfig()
zoneConfig.RangeMaxBytes = proto.Int64(5000)
config.TestingSetZoneConfig(last+1, zoneConfig)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/changefeedccl/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cockroachdb/apd"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdctest"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -329,7 +330,6 @@ func forceTableGC(
database, table string,
) {
t.Helper()
if err := tsi.ForceTableGC(context.TODO(), database, table, tsi.Clock().Now()); err != nil {
t.Fatal(err)
}
sqlutils.ForceTableGC(
t, tsi.DistSenderI().(*kv.DistSender), sqlDB.DB, database, table, tsi.Clock().Now())
}
3 changes: 1 addition & 2 deletions pkg/ccl/importccl/exportcsv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
Expand Down Expand Up @@ -53,7 +52,7 @@ func setupExportableBank(t *testing.T, nodes, rows int) (*sqlutils.SQLRunner, st
t.Fatal(err)
}
last := uint32(v.ValueInt())
zoneConfig := zonepb.DefaultZoneConfig()
zoneConfig := config.DefaultZoneConfig()
zoneConfig.RangeMaxBytes = proto.Int64(5000)
config.TestingSetZoneConfig(last+1, zoneConfig)
db.Exec(t, "ALTER TABLE bank SCATTER")
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/importccl/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"math/rand"

"github.com/cockroachdb/cockroach/pkg/ccl/backupccl"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/internal/client"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
Expand Down Expand Up @@ -54,7 +54,7 @@ func Load(
tempPrefix string,
) (backupccl.BackupDescriptor, error) {
if loadChunkBytes == 0 {
loadChunkBytes = *zonepb.DefaultZoneConfig().RangeMaxBytes / 2
loadChunkBytes = *config.DefaultZoneConfig().RangeMaxBytes / 2
}

var txCtx transform.ExprTransformContext
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/partitionccl/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
Expand All @@ -26,7 +26,7 @@ import (
"github.com/pkg/errors"
)

func subzoneExists(cfg *zonepb.ZoneConfig, index uint32, partition string) bool {
func subzoneExists(cfg *config.ZoneConfig, index uint32, partition string) bool {
for _, s := range cfg.Subzones {
if s.IndexID == index && s.PartitionName == partition {
return true
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestDropIndexWithZoneConfigCCL(t *testing.T) {
sqlDB.Exec(t, `DROP INDEX t.kv@i`)
// All zone configs should still exist.
var buf []byte
cfg := &zonepb.ZoneConfig{}
cfg := &config.ZoneConfig{}
sqlDB.QueryRow(t, "SELECT config FROM system.zones WHERE id = $1", tableDesc.ID).Scan(&buf)
if err := protoutil.Unmarshal(buf, cfg); err != nil {
t.Fatal(err)
Expand Down
10 changes: 5 additions & 5 deletions pkg/ccl/partitionccl/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/ccl/importccl"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/server"
Expand Down Expand Up @@ -98,7 +98,7 @@ type partitioningTest struct {
zoneConfigStmts string

// subzones are the `configs` shorthand parsed into Subzones.
subzones []zonepb.Subzone
subzones []config.Subzone
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (pt *partitioningTest) parse() error {
}

var indexName string
var subzone zonepb.Subzone
var subzone config.Subzone
subzoneParts := strings.Split(subzoneShort, ".")
switch len(subzoneParts) {
case 1:
Expand Down Expand Up @@ -191,7 +191,7 @@ func (pt *partitioningTest) parse() error {
}
}

var parsedConstraints zonepb.ConstraintsList
var parsedConstraints config.ConstraintsList
if err := yaml.UnmarshalStrict([]byte("["+constraints+"]"), &parsedConstraints); err != nil {
return errors.Wrapf(err, "parsing constraints: %s", constraints)
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func verifyScansOnNode(
func setupPartitioningTestCluster(
ctx context.Context, t testing.TB,
) (*gosql.DB, *sqlutils.SQLRunner, func()) {
cfg := zonepb.DefaultZoneConfig()
cfg := config.DefaultZoneConfig()
cfg.NumReplicas = proto.Int32(1)

tsArgs := func(attr string) base.TestServerArgs {
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/partitionccl/zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
Expand Down Expand Up @@ -48,9 +48,9 @@ func TestValidIndexPartitionSetShowZones(t *testing.T) {
yamlDefault := fmt.Sprintf("gc: {ttlseconds: %d}", s.(*server.TestServer).Cfg.DefaultZoneConfig.GC.TTLSeconds)
yamlOverride := "gc: {ttlseconds: 42}"
zoneOverride := s.(*server.TestServer).Cfg.DefaultZoneConfig
zoneOverride.GC = &zonepb.GCPolicy{TTLSeconds: 42}
partialZoneOverride := *zonepb.NewZoneConfig()
partialZoneOverride.GC = &zonepb.GCPolicy{TTLSeconds: 42}
zoneOverride.GC = &config.GCPolicy{TTLSeconds: 42}
partialZoneOverride := *config.NewZoneConfig()
partialZoneOverride.GC = &config.GCPolicy{TTLSeconds: 42}

dbID := sqlutils.QueryDatabaseID(t, db, "d")
tableID := sqlutils.QueryTableID(t, db, "d", "t")
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
Expand Down Expand Up @@ -106,8 +106,8 @@ func initCLIDefaults() {
serverCfg.DelayedBootstrapFn = nil
serverCfg.SocketFile = ""
serverCfg.JoinList = nil
serverCfg.DefaultZoneConfig = zonepb.DefaultZoneConfig()
serverCfg.DefaultSystemZoneConfig = zonepb.DefaultSystemZoneConfig()
serverCfg.DefaultZoneConfig = config.DefaultZoneConfig()
serverCfg.DefaultSystemZoneConfig = config.DefaultSystemZoneConfig()

startCtx.serverInsecure = baseCfg.Insecure
startCtx.serverSSLCertsDir = base.DefaultCertsDirectory
Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

"github.com/cockroachdb/cockroach/pkg/cli/syncbench"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/gossip"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
Expand Down Expand Up @@ -539,7 +538,7 @@ func runDebugGCCmd(cmd *cobra.Command, args []string) error {
&desc,
snap,
hlc.Timestamp{WallTime: timeutil.Now().UnixNano()},
zonepb.GCPolicy{TTLSeconds: int32(gcTTLInSeconds)},
config.GCPolicy{TTLSeconds: int32(gcTTLInSeconds)},
storage.NoopGCer{},
func(_ context.Context, _ []roachpb.Intent) error { return nil },
func(_ context.Context, _ *roachpb.Transaction, _ []roachpb.Intent) error { return nil },
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/github-pull-request-make/testdata/10305.diff
Original file line number Diff line number Diff line change
Expand Up @@ -4533,7 +4533,7 @@ index 3c820233240..245a210d19b 100644
repl *Replica,
+ status *LeaseStatus,
desc *roachpb.RangeDescriptor,
zone zonepb.ZoneConfig,
zone config.ZoneConfig,
checkTransferLeaseSource bool,
@@ -398,7 +399,7 @@ func (rq *replicateQueue) transferLease(
); target != (roachpb.ReplicaDescriptor{}) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/gossipsim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import (
"strconv"
"strings"

"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/gossip"
"github.com/cockroachdb/cockroach/pkg/gossip/simulation"
"github.com/cockroachdb/cockroach/pkg/roachpb"
Expand Down Expand Up @@ -303,7 +303,7 @@ func main() {
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())

n := simulation.NewNetwork(stopper, nodeCount, true, zonepb.DefaultZoneConfigRef())
n := simulation.NewNetwork(stopper, nodeCount, true, config.DefaultZoneConfigRef())
n.SimulateNetwork(
func(cycle int, network *simulation.Network) bool {
// Output dot graph.
Expand Down
7 changes: 5 additions & 2 deletions pkg/config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ import (
// MakeZoneKeyPrefix returns the key prefix for id's row in the system.zones
// table.
func MakeZoneKeyPrefix(id uint32) roachpb.Key {
return keys.ZoneKeyPrefix(id)
k := keys.MakeTablePrefix(uint32(keys.ZonesTableID))
k = encoding.EncodeUvarintAscending(k, uint64(keys.ZonesTablePrimaryIndexID))
return encoding.EncodeUvarintAscending(k, uint64(id))
}

// MakeZoneKey returns the key for id's entry in the system.zones table.
func MakeZoneKey(id uint32) roachpb.Key {
return keys.ZoneKey(id)
k := MakeZoneKeyPrefix(id)
return keys.MakeFamilyKey(k, uint32(keys.ZonesTableConfigColFamID))
}

// DecodeObjectID decodes the object ID from the front of key. It returns the
Expand Down
Loading

0 comments on commit 0cf7360

Please sign in to comment.