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

disttask: fix upgrade missing create framework_meta #47744

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
16 changes: 14 additions & 2 deletions pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,13 +1008,17 @@ const (
version175 = 175

// version 176
// add `mysql.tidb_global_task_history`.
// add `mysql.tidb_global_task_history`
version176 = 176

// version 177
// add `mysql.dist_framework_meta`
version177 = 177
)

// currentBootstrapVersion is defined as a variable, so we can modify its value for testing.
// please make sure this is the largest version
var currentBootstrapVersion int64 = version176
var currentBootstrapVersion int64 = version177

// DDL owner key's expired time is ManagerSessionTTL seconds, we should wait the time and give more time to have a chance to finish it.
var internalSQLTimeout = owner.ManagerSessionTTL + 15
Expand Down Expand Up @@ -1166,6 +1170,7 @@ var (
upgradeToVer174,
upgradeToVer175,
upgradeToVer176,
upgradeToVer177,
}
)

Expand Down Expand Up @@ -2829,6 +2834,13 @@ func upgradeToVer176(s Session, ver int64) {
mustExecute(s, CreateGlobalTaskHistory)
}

func upgradeToVer177(s Session, ver int64) {
if ver >= version177 {
return
}
doReentrantDDL(s, CreateDistFrameworkMeta, infoschema.ErrTableExists)
}

func writeOOMAction(s Session) {
comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+"
mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`,
Expand Down
31 changes: 31 additions & 0 deletions pkg/session/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2085,5 +2085,36 @@ func TestTiDBUpgradeToVer176(t *testing.T) {
ver, err = getBootstrapVersion(seV175)
require.NoError(t, err)
require.Less(t, int64(ver175), ver)
MustExec(t, seV175, "SELECT * from mysql.tidb_global_task_history")
dom.Close()
}

func TestTiDBUpgradeToVer177(t *testing.T) {
store, _ := CreateStoreAndBootstrap(t)
defer func() {
require.NoError(t, store.Close())
}()
ver176 := version176
seV176 := CreateSessionAndSetID(t, store)
txn, err := store.Begin()
require.NoError(t, err)
m := meta.NewMeta(txn)
err = m.FinishBootstrap(int64(ver176))
require.NoError(t, err)
MustExec(t, seV176, fmt.Sprintf("update mysql.tidb set variable_value=%d where variable_name='tidb_server_version'", ver176))
err = txn.Commit(context.Background())
require.NoError(t, err)

unsetStoreBootstrapped(store.UUID())
ver, err := getBootstrapVersion(seV176)
require.NoError(t, err)
require.Equal(t, int64(ver176), ver)

dom, err := BootstrapSession(store)
require.NoError(t, err)
ver, err = getBootstrapVersion(seV176)
require.NoError(t, err)
require.Less(t, int64(ver176), ver)
MustExec(t, seV176, "SELECT * from mysql.dist_framework_meta")
dom.Close()
}