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

Make DROP/CREATE DATABASE pluggable #7381

Merged
merged 27 commits into from
Mar 11, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b7400d4
Start of making CREATE DATABASE pluggable
systay Jan 26, 2021
f85d458
use more restrictive type
systay Jan 26, 2021
768719e
use simpler API for the CREATE DB API
systay Jan 26, 2021
9d200e1
Merge remote-tracking branch 'upstream/master' into create-database
systay Feb 22, 2021
668b66f
make it possible to do both create and drop using a plugin
systay Feb 22, 2021
80b184f
adressed PR review
systay Mar 2, 2021
b324b06
Merge remote-tracking branch 'upstream/master' into create-database
systay Mar 2, 2021
7e776c8
[wip] refactored lots of things
systay Mar 3, 2021
cd26ee2
code refactor
harshit-gangal Mar 3, 2021
02e49ce
e2e test fir dbddl plugin
harshit-gangal Mar 3, 2021
a429c60
[wip] implement the dbddl primitive
systay Mar 3, 2021
90b697d
implemented more of the primitive
systay Mar 3, 2021
a32812c
Merge remote-tracking branch 'upstream/master' into create-database
systay Mar 3, 2021
6657063
fix the primitive on create db and implement drop db
harshit-gangal Mar 4, 2021
c77f7c5
e2e test for drop db
harshit-gangal Mar 4, 2021
73eb606
fix dbdddl plugin unit test
harshit-gangal Mar 4, 2021
c8569f0
dbddl: code refactor
harshit-gangal Mar 4, 2021
295f848
added comments to dbddl
harshit-gangal Mar 4, 2021
10daa0e
added comments directive to set query timeout in db ddl primitive
harshit-gangal Mar 4, 2021
131c5f9
added timeout test
harshit-gangal Mar 5, 2021
9a33429
drop database to wait for vschema to be updated
harshit-gangal Mar 8, 2021
afd6e57
fix plan test
harshit-gangal Mar 9, 2021
6a92f2d
on drop database call, check if keyspace is removed from vschema
harshit-gangal Mar 9, 2021
06da2d7
check resolve destination for drop database to see if keyspace is not…
harshit-gangal Mar 10, 2021
00bf410
Merge branch 'master' of github.com:vitessio/vitess into create-database
harshit-gangal Mar 11, 2021
e762d58
make sure to not return error when things worked
systay Mar 11, 2021
6a7f295
watch vschema in drop database to confirm that the keyspace is no lon…
harshit-gangal Mar 11, 2021
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
Prev Previous commit
Next Next commit
check resolve destination for drop database to see if keyspace is not…
… available

Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Mar 10, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 06da2d7e228e45763b11946df5369ff710a37779
25 changes: 5 additions & 20 deletions go/test/endtoend/vtgate/createdb_plugin/main_test.go
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
}

// Start vtgate
clusterInstance.VtGateExtraArgs = []string{"-dbddl_plugin", "noop"}
clusterInstance.VtGateExtraArgs = []string{"-dbddl_plugin", "noop", "-mysql_server_query_timeout", "60s"}
vtgateProcess := clusterInstance.NewVtgateInstance()
vtgateProcess.SysVarSetEnabled = true
if err := vtgateProcess.Setup(); err != nil {
@@ -114,7 +114,7 @@ func TestDBDDLPlugin(t *testing.T) {
_ = exec(t, conn, `drop database aaa`)
}()
time.Sleep(300 * time.Millisecond)
shutdown("aaa")
shutdown(t, "aaa")

// wait until the drop database query has returned
wg.Wait()
@@ -132,24 +132,9 @@ func start(t *testing.T, ksName string) {
"new database creation failed")
}

func shutdown(ksName string) {
for _, ks := range clusterInstance.Keyspaces {
if ks.Name != ksName {
continue
}
for _, shard := range ks.Shards {
for _, tablet := range shard.Vttablets {
if tablet.MysqlctlProcess.TabletUID > 0 {
tablet.MysqlctlProcess.StopProcess()
}
if tablet.MysqlctldProcess.TabletUID > 0 {
tablet.MysqlctldProcess.Stop()
}
tablet.VttabletProcess.TearDown()
}
}
}
_ = clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteKeyspace", "-recursive", ksName)
func shutdown(t *testing.T, ksName string) {
require.NoError(t,
clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteKeyspace", "-recursive", ksName))
}

func exec(t *testing.T, conn *mysql.Conn, query string) *sqltypes.Result {
8 changes: 7 additions & 1 deletion go/vt/vtgate/engine/dbddl.go
Original file line number Diff line number Diff line change
@@ -169,7 +169,13 @@ func (c *DBDDL) dropDatabase(vcursor VCursor, plugin DBDDLPlugin) (*sqltypes.Res
if err != nil {
return nil, err
}
for vcursor.FindKeyspace(c.name) {
for {
// loop until we do not find the keyspace to resolve.
_, _, err = vcursor.ResolveDestinations(c.name, nil, []key.Destination{})
if err != nil && strings.Contains(err.Error(), "node doesn't exist") {
break
}

select {
case <-ctx.Done(): //context cancelled
return nil, vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "could not validate drop database")
8 changes: 0 additions & 8 deletions go/vt/vtgate/engine/fake_vcursor_test.go
Original file line number Diff line number Diff line change
@@ -57,10 +57,6 @@ type noopVCursor struct {
ctx context.Context
}

func (t *noopVCursor) FindKeyspace(ks string) bool {
panic("implement me")
}

func (t *noopVCursor) SetDDLStrategy(strategy string) {
panic("implement me")
}
@@ -276,10 +272,6 @@ type loggingVCursor struct {
dbDDLPlugin string
}

func (f *loggingVCursor) FindKeyspace(ks string) bool {
return len(f.shards) > 0
}

type tableRoutes struct {
tbl *vindexes.Table
}
2 changes: 0 additions & 2 deletions go/vt/vtgate/engine/primitive.go
Original file line number Diff line number Diff line change
@@ -101,8 +101,6 @@ type (

// GetDBDDLPlugin gets the configured plugin for DROP/CREATE DATABASE
GetDBDDLPluginName() string

FindKeyspace(ks string) bool
}

//SessionActions gives primitives ability to interact with the session state
4 changes: 0 additions & 4 deletions go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
@@ -698,10 +698,6 @@ func (vc *vcursorImpl) GetDBDDLPluginName() string {
return *dbDDLPlugin
}

func (vc *vcursorImpl) FindKeyspace(ks string) bool {
return vc.KeyspaceExists(ks)
}

// ParseDestinationTarget parses destination target string and sets default keyspace if possible.
func parseDestinationTarget(targetString string, vschema *vindexes.VSchema) (string, topodatapb.TabletType, key.Destination, error) {
destKeyspace, destTabletType, dest, err := topoprotopb.ParseDestination(targetString, defaultTabletType)