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

Refactor code to remove evalengine as a dependency of VTOrc #13642

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions go/cmd/vtcombo/vschema_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
vschemapb "vitess.io/vitess/go/vt/proto/vschema"
vttestpb "vitess.io/vitess/go/vt/proto/vttest"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/vtgate/vindexes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move vindexes outside of vtgate as well here since we use it in many others? Is it worth moving it to go/vt/vindexes for example then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should move it out, but that can also be a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't want to do that in this PR.

)

func startVschemaWatcher(vschemaPersistenceDir string, keyspaces []*vttestpb.Keyspace, ts *topo.Server) {
Expand Down Expand Up @@ -61,6 +62,10 @@ func loadKeyspacesFromDir(dir string, keyspaces []*vttestpb.Keyspace, ts *topo.S
log.Fatalf("Unable to parse keyspace file %v: %v", ksFile, err)
}

_, err = vindexes.BuildKeyspace(keyspace)
if err != nil {
log.Fatalf("Invalid keyspace definition: %v", err)
}
ts.SaveVSchema(context.Background(), ks.Name, keyspace)
log.Infof("Loaded keyspace %v from %v\n", ks.Name, ksFile)
}
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/vtctldclient/command/keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/cli"
"vitess.io/vitess/go/constants/sidecar"
"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 Down Expand Up @@ -425,7 +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.")
CreateKeyspace.Flags().StringVar(&createKeyspaceOptions.SidecarDBName, "sidecar-db-name", sidecar.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
42 changes: 42 additions & 0 deletions go/constants/sidecar/name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2023 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package sidecar

GuptaManan100 marked this conversation as resolved.
Show resolved Hide resolved
import (
"sync/atomic"
)

const (
DefaultName = "_vt"
)

var (
// This should be accessed via GetName()
sidecarDBName atomic.Value
)

func init() {
sidecarDBName.Store(DefaultName)
}

func SetName(name string) {
sidecarDBName.Store(name)
}

func GetName() string {
return sidecarDBName.Load().(string)
}
8 changes: 4 additions & 4 deletions go/test/endtoend/cluster/cluster_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ import (
"testing"
"time"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/json2"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/test/endtoend/filelock"
"vitess.io/vitess/go/vt/grpcclient"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext"
"vitess.io/vitess/go/vt/vtgate/vtgateconn"
Expand Down Expand Up @@ -329,7 +329,7 @@ func (cluster *LocalProcessCluster) startKeyspace(keyspace Keyspace, shardNames

log.Infof("Starting keyspace: %v", keyspace.Name)
if keyspace.SidecarDBName == "" {
keyspace.SidecarDBName = sidecardb.DefaultName
keyspace.SidecarDBName = sidecar.DefaultName
}
// Create the keyspace if it doesn't already exist.
_ = cluster.VtctlProcess.CreateKeyspace(keyspace.Name, keyspace.SidecarDBName)
Expand Down Expand Up @@ -482,7 +482,7 @@ func (cluster *LocalProcessCluster) StartKeyspaceLegacy(keyspace Keyspace, shard

log.Infof("Starting keyspace: %v", keyspace.Name)
if keyspace.SidecarDBName == "" {
keyspace.SidecarDBName = sidecardb.DefaultName
keyspace.SidecarDBName = sidecar.DefaultName
}
// Create the keyspace if it doesn't already exist.
_ = cluster.VtctlProcess.CreateKeyspace(keyspace.Name, keyspace.SidecarDBName)
Expand Down Expand Up @@ -623,7 +623,7 @@ func (cluster *LocalProcessCluster) SetupCluster(keyspace *Keyspace, shards []Sh
log.Infof("Starting keyspace: %v", keyspace.Name)

if keyspace.SidecarDBName == "" {
keyspace.SidecarDBName = sidecardb.DefaultName
keyspace.SidecarDBName = sidecar.DefaultName
}

if !cluster.ReusingVTDATAROOT {
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/cluster/vttablet_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
"testing"
"time"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/sqlparser"
)

Expand Down Expand Up @@ -519,7 +519,7 @@ func (vttablet *VttabletProcess) ToggleProfiling() error {
// WaitForVReplicationToCatchup waits for "workflow" to finish copying
func (vttablet *VttabletProcess) WaitForVReplicationToCatchup(t testing.TB, workflow, database string, sidecarDBName string, duration time.Duration) {
if sidecarDBName == "" {
sidecarDBName = sidecardb.DefaultName
sidecarDBName = sidecar.DefaultName
}
// Escape it if/as needed
ics := sqlparser.NewIdentifierCS(sidecarDBName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/encryption"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand Down Expand Up @@ -131,7 +131,7 @@ func initializeCluster(t *testing.T) (int, error) {
for _, keyspaceStr := range []string{keyspace} {
KeyspacePtr := &cluster.Keyspace{Name: keyspaceStr}
keyspace := *KeyspacePtr
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspace.Name, sidecardb.DefaultName); err != nil {
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspace.Name, sidecar.DefaultName); err != nil {
return 1, err
}
shard := &cluster.Shard{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ import (

"github.com/pkg/errors"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/encryption"

"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/vterrors"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -350,7 +350,7 @@ func clusterSetUp(t *testing.T) (int, error) {
for _, keyspaceStr := range []string{keyspace} {
KeyspacePtr := &cluster.Keyspace{Name: keyspaceStr}
keyspace := *KeyspacePtr
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspace.Name, sidecardb.DefaultName); err != nil {
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspace.Name, sidecar.DefaultName); err != nil {
return 1, err
}
shard := &cluster.Shard{
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/mysqlctl/mysqlctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand All @@ -53,7 +53,7 @@ func TestMain(m *testing.M) {
return 1
}

if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecardb.DefaultName); err != nil {
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecar.DefaultName); err != nil {
return 1
}

Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/mysqlctld/mysqlctld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/vt/mysqlctl/mysqlctlclient"

"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand All @@ -56,7 +56,7 @@ func TestMain(m *testing.M) {
return 1
}

if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecardb.DefaultName); err != nil {
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecar.DefaultName); err != nil {
return 1
}

Expand Down
6 changes: 3 additions & 3 deletions go/test/endtoend/recovery/pitr/shardedpitr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/utils"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand Down Expand Up @@ -304,8 +304,8 @@ func performResharding(t *testing.T) {
require.NoError(t, err)

waitTimeout := 30 * time.Second
shard0Primary.VttabletProcess.WaitForVReplicationToCatchup(t, "ks.reshardWorkflow", dbName, sidecardb.DefaultName, waitTimeout)
shard1Primary.VttabletProcess.WaitForVReplicationToCatchup(t, "ks.reshardWorkflow", dbName, sidecardb.DefaultName, waitTimeout)
shard0Primary.VttabletProcess.WaitForVReplicationToCatchup(t, "ks.reshardWorkflow", dbName, sidecar.DefaultName, waitTimeout)
shard1Primary.VttabletProcess.WaitForVReplicationToCatchup(t, "ks.reshardWorkflow", dbName, sidecar.DefaultName, waitTimeout)

waitForNoWorkflowLag(t, clusterInstance, "ks.reshardWorkflow")

Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/sharded/sharded_keyspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestMain(m *testing.M) {
if err := clusterInstance.StartTopo(); err != nil {
return 1, err
}
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecardb.DefaultName); err != nil {
if err := clusterInstance.VtctlProcess.CreateKeyspace(keyspaceName, sidecar.DefaultName); err != nil {
return 1, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/utils"
"vitess.io/vitess/go/vt/sidecardb"
)

var (
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestMain(m *testing.M) {
// For upgrade/downgrade tests.
if vtgateVer < 17 || vttabletVer < 17 {
// Then only the default sidecarDBName is supported.
sidecarDBName = sidecardb.DefaultName
sidecarDBName = sidecar.DefaultName
}

// Start topo server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import (
"testing"
"time"

"vitess.io/vitess/go/vt/sidecardb"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/utils"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -142,7 +141,7 @@ func TestMain(m *testing.M) {
// For upgrade/downgrade tests.
if vtgateVer < 17 || vttabletVer < 17 {
// Then only the default sidecarDBName is supported.
sidecarDBName = sidecardb.DefaultName
sidecarDBName = sidecar.DefaultName
}

clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs, "--schema_change_signal")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
"testing"
"time"

"vitess.io/vitess/go/test/endtoend/utils"
"vitess.io/vitess/go/vt/sidecardb"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/test/endtoend/utils"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
)
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestMain(m *testing.M) {
// For upgrade/downgrade tests.
if vtgateVer < 17 || vttabletVer < 17 {
// Then only the default sidecarDBName is supported.
sidecarDBName = sidecardb.DefaultName
sidecarDBName = sidecar.DefaultName
}

// Start topo server
Expand Down
6 changes: 3 additions & 3 deletions go/vt/binlog/binlogplayer/dbclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"context"
"fmt"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/sqlparser"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ type dbClientImplWithSidecarDBReplacement struct {

// NewDBClient creates a DBClient instance
func NewDBClient(params dbconfigs.Connector) DBClient {
if sidecardb.GetName() != sidecardb.DefaultName {
if sidecar.GetName() != sidecar.DefaultName {
return &dbClientImplWithSidecarDBReplacement{
dbClientImpl{dbConfig: params},
}
Expand Down Expand Up @@ -141,7 +141,7 @@ func (dc *dbClientImpl) ExecuteFetch(query string, maxrows int) (*sqltypes.Resul

func (dcr *dbClientImplWithSidecarDBReplacement) ExecuteFetch(query string, maxrows int) (*sqltypes.Result, error) {
// Replace any provided sidecar database qualifiers with the correct one.
uq, err := sqlparser.ReplaceTableQualifiers(query, sidecardb.DefaultName, sidecardb.GetName())
uq, err := sqlparser.ReplaceTableQualifiers(query, sidecar.DefaultName, sidecar.GetName())
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions go/vt/mysqlctl/reparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ This file contains the reparenting methods for mysqlctl.
*/

import (
"context"
"time"

"vitess.io/vitess/go/vt/sidecardb"
"vitess.io/vitess/go/vt/sqlparser"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/log"

"context"
)

// GenerateInitialBinlogEntry is used to create a binlog entry when
Expand Down
3 changes: 2 additions & 1 deletion go/vt/sidecardb/identifier_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync/atomic"
"time"

"vitess.io/vitess/go/constants/sidecar"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vterrors"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (ic *IdentifierCache) Get(keyspace string) (string, error) {
return "", err
}
if sdbname == "" {
sdbname = DefaultName
sdbname = sidecar.DefaultName
}

sdbid = sqlparser.String(sqlparser.NewIdentifierCS(sdbname))
Expand Down
Loading