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

server: only owner do bootstrap #10029

Merged
merged 13 commits into from
Apr 11, 2019
28 changes: 18 additions & 10 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/pingcap/parser/mysql"
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/chunk"
Expand Down Expand Up @@ -250,17 +251,24 @@ const (

// bootstrap initiates system DB for a store.
func bootstrap(s Session) {
b, err := checkBootstrapped(s)
if err != nil {
logutil.Logger(context.Background()).Fatal("check bootstrap error",
zap.Error(err))
}
if b {
upgrade(s)
return
dom := domain.GetDomain(s)
for {
b, err := checkBootstrapped(s)
if err != nil {
logutil.Logger(context.Background()).Fatal("check bootstrap error",
zap.Error(err))
}
if b {
upgrade(s)
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
return
}
if dom.DDL().OwnerManager().IsOwner() {
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
doDDLWorks(s)
doDMLWorks(s)
return
}
time.Sleep(50 * time.Millisecond)
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
}
doDDLWorks(s)
doDMLWorks(s)
}

const (
Expand Down