Skip to content

Commit

Permalink
session: upgrade from old cluster infoschema v2 should not be used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Oct 22, 2024
1 parent 3792db2 commit d123c9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion br/pkg/restore/snap_client/systable_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ func TestCheckSysTableCompatibility(t *testing.T) {
//
// The above variables are in the file br/pkg/restore/systable_restore.go
func TestMonitorTheSystemTableIncremental(t *testing.T) {
require.Equal(t, int64(216), session.CurrentBootstrapVersion)
require.Equal(t, int64(217), session.CurrentBootstrapVersion)
}
16 changes: 15 additions & 1 deletion pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,11 +1182,15 @@ const (
// version 216
// changes variable `tidb_scatter_region` value from ON to "table" and OFF to "".
version216 = 216

// version 217
// Keep tidb_schema_cache_size to 0 if this variable does not exist (upgrading from old version pre 8.1).
version217 = 217
)

// 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 = version216
var currentBootstrapVersion int64 = version217

// 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 @@ -1358,6 +1362,7 @@ var (
upgradeToVer214,
upgradeToVer215,
upgradeToVer216,
upgradeToVer217,
}
)

Expand Down Expand Up @@ -3267,6 +3272,15 @@ func upgradeToVer216(s sessiontypes.Session, ver int64) {
mustExecute(s, "UPDATE mysql.global_variables SET VARIABLE_VALUE='table' WHERE VARIABLE_NAME = 'tidb_scatter_region' AND VARIABLE_VALUE = 'ON'")
}

func upgradeToVer217(s sessiontypes.Session, ver int64) {
if ver >= version217 {
return
}
// If tidb_schema_cache_size does not exist, insert a record and set the value to 0
// Otherwise do nothing.
mustExecute(s, "INSERT IGNORE INTO mysql.global_variables VALUES ('tidb_schema_cache_size', 0)")
}

// initGlobalVariableIfNotExists initialize a global variable with specific val if it does not exist.
func initGlobalVariableIfNotExists(s sessiontypes.Session, name string, val any) {
ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnBootstrap)
Expand Down

0 comments on commit d123c9f

Please sign in to comment.