Skip to content

Commit

Permalink
Fix vtcombo DBDDL plugin race condition (vitessio#13117)
Browse files Browse the repository at this point in the history
Signed-off-by: Jaskanwal Pawar <32091345+jspawar@users.noreply.github.com>
Co-authored-by: Arthur Schreiber <arthurschreiber@github.com>
  • Loading branch information
vitess-bot[bot] and arthurschreiber committed Aug 8, 2023
1 parent 64fa0b1 commit 01f621a
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 01f621a

Please sign in to comment.