Skip to content

Commit

Permalink
Merge branch 'master' into rustin-patch-queue-v2-to-queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 authored Oct 21, 2024
2 parents 1d64931 + 43b4336 commit a20b2e2
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 @@ -1183,11 +1183,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 @@ -1359,6 +1363,7 @@ var (
upgradeToVer214,
upgradeToVer215,
upgradeToVer216,
upgradeToVer217,
}
)

Expand Down Expand Up @@ -3268,6 +3273,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 a20b2e2

Please sign in to comment.