Skip to content

Commit

Permalink
Move from vttablet flag to topo Keyspace record
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Feb 13, 2023
1 parent 75adbc1 commit 61f7e61
Show file tree
Hide file tree
Showing 19 changed files with 1,368 additions and 1,136 deletions.
8 changes: 8 additions & 0 deletions examples/common/scripts/vtctld-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ vtctld \
--grpc_port $grpc_port \
--pid_file $VTDATAROOT/tmp/vtctld.pid \
> $VTDATAROOT/tmp/vtctld.out 2>&1 &

for i in $(seq 0 300); do
curl -I "http://$hostname:$vtctld_web_port/debug/status" >/dev/null 2>&1 && break
sleep 0.1
done

# check one last time
curl -I "http://$hostname:$vtctld_web_port/debug/status" || fail "vtctld could not be started!"
1 change: 0 additions & 1 deletion examples/common/scripts/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ vttablet \
--pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \
--vtctld_addr http://$hostname:$vtctld_web_port/ \
--disable_active_reparents \
--sidecar-db-name '_vt_test' \
> $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 &

# Block waiting for the tablet to be listening
Expand Down
9 changes: 6 additions & 3 deletions examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

source ../common/env.sh

SIDECAR_DB_NAME=${SIDECAR_DB_NAME:-"_vt_test"}

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

# Create the keyspace with a non-default sidecar database name
# and set the correct durability policy
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
5 changes: 4 additions & 1 deletion go/cmd/vtctldclient/command/keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 +136,7 @@ var createKeyspaceOptions = struct {
BaseKeyspace string
SnapshotTimestamp string
DurabilityPolicy string
SidecarDBName string
}{
KeyspaceType: cli.KeyspaceTypeFlag(topodatapb.KeyspaceType_NORMAL),
}
Expand Down Expand Up @@ -185,6 +186,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 @@ -407,6 +409,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", "_vt", "Vitess sidecar database used 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
2 changes: 0 additions & 2 deletions go/cmd/vttablet/vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/tableacl"
"vitess.io/vitess/go/vt/tableacl/simpleacl"
"vitess.io/vitess/go/vt/topo"
Expand Down Expand Up @@ -66,7 +65,6 @@ func registerFlags(fs *pflag.FlagSet) {
fs.StringVar(&tabletConfig, "tablet_config", tabletConfig, "YAML file config for tablet")

acl.RegisterFlags(fs)
sidecardb.RegisterFlags(fs)
}

func init() {
Expand Down
1 change: 0 additions & 1 deletion go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ Usage of vttablet:
--serving_state_grace_period duration how long to pause after broadcasting health to vtgate, before enforcing a new serving state
--shard_sync_retry_delay duration delay between retries of updates to keep the tablet and its shard record in sync (default 30s)
--shutdown_grace_period float how long to wait (in seconds) for queries and transactions to complete during graceful shutdown.
--sidecar-db-name string Name of the Vitess sidecar database used for internal metadata. (default "_vt")
--sql-max-length-errors int truncate queries in error logs to the given length (default unlimited)
--sql-max-length-ui int truncate queries in debug UIs to the given length (default 512) (default 512)
--srv_topo_cache_refresh duration how frequently to refresh the topology for cached entries (default 1s)
Expand Down
Loading

0 comments on commit 61f7e61

Please sign in to comment.