-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
69169: sql: allow secondary tenants to set/show zone configurations r=irfansharif,ajwerner a=arulajmani Part of #67679. The zone configurations themselves have no effect right now. See individual commits for details. 69185: cli,sql/sem/builtins: emit_defaults to false for decode-proto, pb_to_json r=dt a=ajwerner When `cockroach debug decode-proto` and `crdb_internal.pb_to_json` were first added, they emitted the default values in the produced json. This turns out to not be desirable; setting emit defaults to false produces json which round- trips back to the same proto. Release note (cli change): `cockroach debug decode-proto` now does not emit default values by default. Release note (sql change): `crdb_internal.pb_to_json` now does not emit default values by default. Co-authored-by: arulajmani <[email protected]> Co-authored-by: Andrew Werner <[email protected]>
- Loading branch information
Showing
43 changed files
with
410 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
pkg/ccl/logictestccl/testdata/logic_test/zone_config_secondary_tenants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# LogicTest: 3node-tenant | ||
# Zone config logic tests that are only meant to work for secondary tenants. | ||
|
||
statement ok | ||
CREATE TABLE t(); | ||
|
||
statement error pq: unimplemented: operation is unsupported in multi-tenancy mode | ||
ALTER TABLE t CONFIGURE ZONE USING num_replicas = 5; | ||
|
||
statement ok | ||
SET CLUSTER SETTING sql.zone_configs.experimental_allow_for_secondary_tenant.enabled = true | ||
|
||
statement ok | ||
ALTER TABLE t CONFIGURE ZONE USING num_replicas = 5; | ||
|
||
query IT | ||
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1 | ||
---- | ||
0 RANGE default | ||
53 TABLE test.public.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/clusterversion" | ||
"github.com/cockroachdb/cockroach/pkg/config/zonepb" | ||
"github.com/cockroachdb/cockroach/pkg/kv" | ||
"github.com/cockroachdb/cockroach/pkg/migration" | ||
"github.com/cockroachdb/cockroach/pkg/sql/catalog/bootstrap" | ||
"github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" | ||
"github.com/cockroachdb/cockroach/pkg/startupmigrations" | ||
) | ||
|
||
// zonesTableForSecondaryTenants adds system.zones to secondary tenants and | ||
// seeds it. | ||
func zonesTableForSecondaryTenants( | ||
ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, | ||
) error { | ||
if d.Codec.ForSystemTenant() { | ||
// We don't need to add system.zones to the system tenant as it should | ||
// already be present. | ||
return nil | ||
} | ||
if err := startupmigrations.CreateSystemTable( | ||
ctx, d.DB, d.Codec, d.Settings, systemschema.ZonesTable, | ||
); err != nil { | ||
return err | ||
} | ||
defaultZoneConfig := zonepb.DefaultZoneConfigRef() | ||
defaultSystemZoneConfig := zonepb.DefaultSystemZoneConfigRef() | ||
kvs := bootstrap.InitialZoneConfigKVs(d.Codec, defaultZoneConfig, defaultSystemZoneConfig) | ||
return d.DB.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { | ||
b := txn.NewBatch() | ||
for _, kv := range kvs { | ||
b.Put(kv.Key, &kv.Value) | ||
} | ||
return txn.Run(ctx, b) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.