Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Custom SidecarDB Names on VTTablets #12240

Merged
merged 84 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
9714e6b
WIP
mattlord Feb 2, 2023
6781820
vreplication package
mattlord Feb 2, 2023
c377dd1
Revert OnlineDDL package changes for now
mattlord Feb 6, 2023
6d15217
Fix unit tests
mattlord Feb 6, 2023
beac562
Fix InitShardPrimary / ReparentJournal
mattlord Feb 6, 2023
fb488e3
onlineddl package
mattlord Feb 10, 2023
dc1977b
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 10, 2023
cf593f7
Shorten/improve exported func name
mattlord Feb 12, 2023
0ea1f8d
Remaining work
mattlord Feb 12, 2023
abf56e8
Remove redundancy from exported function names
mattlord Feb 13, 2023
c4d6759
Minor changes after self review
mattlord Feb 13, 2023
75adbc1
More testing, more fixes
mattlord Feb 13, 2023
61f7e61
Move from vttablet flag to topo Keyspace record
mattlord Feb 13, 2023
7439aff
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 14, 2023
f247005
Fix vtctld API unit test
mattlord Feb 14, 2023
16c2d4a
Fix TestHelp
mattlord Feb 14, 2023
001a665
Merge branch 'main' into custom_sidecar_db
shlomi-noach Feb 14, 2023
0e897dd
Update throttler service initialization
mattlord Feb 14, 2023
f2c256c
Use custom sidecar in VReplication e2e tests
mattlord Feb 14, 2023
826bdc7
Make sidecardb name concurrecy safe
mattlord Feb 14, 2023
64d45b5
Fix VDiff2 e2e test and remove other hardecoded sidecar names
mattlord Feb 14, 2023
c88e59f
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 14, 2023
b95d698
Adjust throttler initialization
mattlord Feb 14, 2023
d5e716a
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 23, 2023
f058794
Post merge fixes
mattlord Feb 23, 2023
8ca5950
Copy SidecarDBName from global Keyspace object to SrvKeyspace objects
mattlord Feb 24, 2023
1e7c750
Store throttler config in global Keyspace record
mattlord Feb 27, 2023
a1858f2
Update vtadmin protos
mattlord Feb 27, 2023
1e844ad
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 27, 2023
303db96
Fix unit test after ThrottlerConfig in Keyspace
mattlord Feb 27, 2023
e2a8247
SidecarDbName is not needed in SrvKeyspace records
mattlord Feb 28, 2023
7f581f7
Remove sqlparser.ReplaceTableQualifiers from query hot path.
mattlord Feb 28, 2023
96b0ed4
Add topo timeout for SHOW VITESS_MIGRATIONS
mattlord Feb 28, 2023
9ae6d7b
Cache sidecar database identifiers by keyspace
mattlord Feb 28, 2023
ad6c5e4
Modify onlineddl package
mattlord Feb 28, 2023
39ddd72
Revert "Fix unit test after ThrottlerConfig in Keyspace"
mattlord Feb 28, 2023
f1fcb91
Revert "Store throttler config in global Keyspace record"
mattlord Feb 28, 2023
03e5d3d
Finish ThrottlerTopoConfig change rollback
mattlord Feb 28, 2023
3c39494
Add max identifier length check for --sidecar-db-name flag
mattlord Feb 28, 2023
9e4d55e
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Feb 28, 2023
006e6ab
Move vdiff and vreplication packages to binlogplayer.DBClient.Execute…
mattlord Mar 1, 2023
81cd0cc
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 1, 2023
c8cd425
binlogplayer.DBClient: eliminate overhead when default name is used
mattlord Mar 1, 2023
bf8164e
Move keyspace ID look to a helper function
mattlord Mar 2, 2023
57a02ff
Minor cleanup
mattlord Mar 2, 2023
b925d4d
Add context for usage in the local examples
mattlord Mar 5, 2023
ce4d571
Correct CreateKeyspace command's sidecardb flag validation
mattlord Mar 5, 2023
3a6e129
Limit overhead for OnlineDDL package
mattlord Mar 6, 2023
6a76ebe
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 6, 2023
c2d3990
Cleanup and improvements after self review
mattlord Mar 7, 2023
c24b59b
Store each keyspace's sidecar db identifier in schema.Tracker
mattlord Mar 7, 2023
3fefbd5
Enable custom sidecar db name in schema tracker e2e tests
mattlord Mar 7, 2023
3d1063e
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 7, 2023
7f3559b
Fix schema.tracker and its tests
mattlord Mar 7, 2023
93c3746
Better support downgrade tests
mattlord Mar 7, 2023
2746dfd
Always use sqlparser.String() for proper escaping
mattlord Mar 7, 2023
33ef963
Try to fix Upgrade Downgrade Testing Query Serving (Schema)
mattlord Mar 7, 2023
839f2f9
Minor changes after self review.
mattlord Mar 8, 2023
b320ec3
Mark new flag/functionality as experimental
mattlord Mar 8, 2023
9e75101
Remove exclamation point from example error msg
mattlord Mar 8, 2023
4513376
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 8, 2023
3d562d5
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 8, 2023
bf3af88
Merge remote-tracking branch 'origin/main' into custom_sidecar_db
mattlord Mar 9, 2023
d64c84d
Fixups after merge
mattlord Mar 9, 2023
a9be452
More post merge fixes
mattlord Mar 9, 2023
77cb653
Address review comments
mattlord Mar 9, 2023
a16a0cf
Moar knits!
mattlord Mar 10, 2023
e6fed7c
Moar knits -- the sequel
mattlord Mar 10, 2023
d6d14c4
Deflake schematracker e2e tests
mattlord Mar 10, 2023
a382556
Add a dedicated in-memory cache for sidecar db idents
mattlord Mar 10, 2023
1845bd5
Improve sidecardb identifier cache
mattlord Mar 10, 2023
2d6d7fe
More minor improvements
mattlord Mar 10, 2023
9e4ec83
Minor tweaks after final self review
mattlord Mar 11, 2023
38938e2
Minor tidy work
mattlord Mar 11, 2023
cd918b6
Delete entry from cache on srvkeyspace deletion
mattlord Mar 11, 2023
a2d378a
Address review comments.
mattlord Mar 11, 2023
53aaf41
Save me from my nitting! (use vtrpcpb convention)
mattlord Mar 13, 2023
2aadf11
Make IdentifierCache more concurrency-safe than it needs to be (today)
mattlord Mar 13, 2023
2f5ab88
Slighly improve code coverage
mattlord Mar 13, 2023
a24e94a
Let caller know if New created a cache or returned inited singleton.
mattlord Mar 13, 2023
356b91b
Address review comments
mattlord Mar 13, 2023
4b27e86
Use more unique name for unit test
mattlord Mar 13, 2023
da4ee79
Address latest review comments
mattlord Mar 14, 2023
2c11e74
Use lower context for updating keyspace
mattlord Mar 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/common/scripts/vtctld-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ vtctld \
--grpc_port $grpc_port \
--pid_file $VTDATAROOT/tmp/vtctld.pid \
> $VTDATAROOT/tmp/vtctld.out 2>&1 &

for _ in {0..300}; do
curl -I "http://${hostname}:${vtctld_web_port}/debug/status" &>/dev/null && break
sleep 0.1
done

# check one last time
curl -I "http://${hostname}:${vtctld_web_port}/debug/status" &>/dev/null || fail "vtctld could not be started!"

echo -e "vtctld is running!"
18 changes: 15 additions & 3 deletions examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

source ../common/env.sh

# This is done here as a means to support testing the experimental
# custom sidecar database name work in a wide variety of scenarios
# as the local examples are used to test many features locally.
# This is NOT here to indicate that you should normally use a
# non-default (_vt) value or that it is somehow a best practice
# to do so. In production, you should ONLY use a non-default
# sidecar database name when it's truly needed.
SIDECAR_DB_NAME=${SIDECAR_DB_NAME:-"_vt"}

# start topo server
if [ "${TOPO}" = "zk2" ]; then
CELL=zone1 ../common/scripts/zk-up.sh
Expand All @@ -33,15 +42,18 @@ fi
# start vtctld
CELL=zone1 ../common/scripts/vtctld-up.sh

# Create the keyspace with the sidecar database name and set the
# correct durability policy. Please see the comment above for
# more context on using a custom sidecar database name in your
# Vitess clusters.
vtctldclient --server localhost:15999 CreateKeyspace --sidecar-db-name="${SIDECAR_DB_NAME}" --durability-policy=semi_sync commerce || fail "Failed to create and configure the commerce keyspace"

# start vttablets for keyspace commerce
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done

# set the correct durability policy for the keyspace
vtctldclient --server localhost:15999 SetKeyspaceDurabilityPolicy --durability-policy=semi_sync commerce || fail "Failed to set keyspace durability policy on the commerce keyspace"

# start vtorc
../common/scripts/vtorc-up.sh

Expand Down
17 changes: 16 additions & 1 deletion go/cmd/vtctldclient/command/keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ package command
import (
"errors"
"fmt"
"strings"
"time"

"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/cli"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/topo"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
Expand All @@ -35,7 +38,7 @@ import (
var (
// CreateKeyspace makes a CreateKeyspace gRPC call to a vtctld.
CreateKeyspace = &cobra.Command{
Use: "CreateKeyspace <keyspace> [--force|-f] [--type KEYSPACE_TYPE] [--base-keyspace KEYSPACE --snapshot-timestamp TIME] [--served-from DB_TYPE:KEYSPACE ...] [--durability-policy <policy_name>]",
Use: "CreateKeyspace <keyspace> [--force|-f] [--type KEYSPACE_TYPE] [--base-keyspace KEYSPACE --snapshot-timestamp TIME] [--served-from DB_TYPE:KEYSPACE ...] [--durability-policy <policy_name>] [--sidecar-db-name <db_name>]",
Short: "Creates the specified keyspace in the topology.",
Long: `Creates the specified keyspace in the topology.

Expand Down Expand Up @@ -136,6 +139,7 @@ var createKeyspaceOptions = struct {
BaseKeyspace string
SnapshotTimestamp string
DurabilityPolicy string
SidecarDBName string
}{
KeyspaceType: cli.KeyspaceTypeFlag(topodatapb.KeyspaceType_NORMAL),
}
Expand Down Expand Up @@ -175,6 +179,15 @@ func commandCreateKeyspace(cmd *cobra.Command, args []string) error {
snapshotTime = logutil.TimeToProto(t)
}

createKeyspaceOptions.SidecarDBName = strings.TrimSpace(createKeyspaceOptions.SidecarDBName)
if createKeyspaceOptions.SidecarDBName == "" {
return errors.New("--sidecar-db-name cannot be empty when creating a keyspace")
}
if len(createKeyspaceOptions.SidecarDBName) > mysql.MaxIdentifierLength {
return mysql.NewSQLError(mysql.ERTooLongIdent, mysql.SSDataTooLong, "--sidecar-db-name identifier value of %q is too long (%d chars), max length for database identifiers is %d characters",
createKeyspaceOptions.SidecarDBName, len(createKeyspaceOptions.SidecarDBName), mysql.MaxIdentifierLength)
}

cli.FinishedParsing(cmd)

req := &vtctldatapb.CreateKeyspaceRequest{
Expand All @@ -185,6 +198,7 @@ func commandCreateKeyspace(cmd *cobra.Command, args []string) error {
BaseKeyspace: createKeyspaceOptions.BaseKeyspace,
SnapshotTime: snapshotTime,
DurabilityPolicy: createKeyspaceOptions.DurabilityPolicy,
SidecarDbName: createKeyspaceOptions.SidecarDBName,
}

for n, v := range createKeyspaceOptions.ServedFromsMap.StringMapValue {
Expand Down Expand Up @@ -411,6 +425,7 @@ func init() {
CreateKeyspace.Flags().StringVar(&createKeyspaceOptions.BaseKeyspace, "base-keyspace", "", "The base keyspace for a snapshot keyspace.")
CreateKeyspace.Flags().StringVar(&createKeyspaceOptions.SnapshotTimestamp, "snapshot-timestamp", "", "The snapshot time for a snapshot keyspace, as a timestamp in RFC3339 format.")
CreateKeyspace.Flags().StringVar(&createKeyspaceOptions.DurabilityPolicy, "durability-policy", "none", "Type of durability to enforce for this keyspace. Default is none. Possible values include 'semi_sync' and others as dictated by registered plugins.")
CreateKeyspace.Flags().StringVar(&createKeyspaceOptions.SidecarDBName, "sidecar-db-name", sidecardb.DefaultName, "(Experimental) Name of the Vitess sidecar database that tablets in this keyspace will use for internal metadata.")
Root.AddCommand(CreateKeyspace)

DeleteKeyspace.Flags().BoolVarP(&deleteKeyspaceOptions.Recursive, "recursive", "r", false, "Recursively delete all shards in the keyspace, and all tablets in those shards.")
Expand Down
Loading