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) #10426

Merged
merged 1 commit into from
May 13, 2019
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
31 changes: 21 additions & 10 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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 @@ -214,17 +215,27 @@ 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))
}
// For rolling upgrade, we can't do upgrade only in the owner.
if b {
upgrade(s)
return
}
// To reduce conflict when multiple TiDB-server start at the same time.
// Actually only one server need to do the bootstrap. So we chose DDL owner to do this.
if dom.DDL().OwnerManager().IsOwner() {
doDDLWorks(s)
doDMLWorks(s)
return
}
time.Sleep(200 * time.Millisecond)
}
doDDLWorks(s)
doDMLWorks(s)
}

const (
Expand Down