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

[release-16.0] Fix vtcombo DBDDL plugin race condition (#13117) #13741

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
7 changes: 6 additions & 1 deletion go/cmd/vtcombo/plugin_dbddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
"sync"

"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/vtgate/engine"
Expand All @@ -29,7 +30,9 @@ var globalCreateDb func(ctx context.Context, ks *vttestpb.Keyspace) error
var globalDropDb func(ctx context.Context, ksName string) error

// DBDDL doesn't need to store any state - we use the global variables above instead
type DBDDL struct{}
type DBDDL struct {
mu sync.Mutex
}

// CreateDatabase implements the engine.DBDDLPlugin interface
func (plugin *DBDDL) CreateDatabase(ctx context.Context, name string) error {
Expand All @@ -39,6 +42,8 @@ func (plugin *DBDDL) CreateDatabase(ctx context.Context, name string) error {
Name: "0",
}},
}
plugin.mu.Lock()
defer plugin.mu.Unlock()
return globalCreateDb(ctx, ks)
}

Expand Down
Loading