br: avoid too many warning logs after update schema version (#43416)
close pingcap/tidb#43402
This commit is contained in:
@ -3072,8 +3072,20 @@ func (rc *Client) UpdateSchemaVersion(ctx context.Context) error {
|
||||
func(ctx context.Context, txn kv.Transaction) error {
|
||||
t := meta.NewMeta(txn)
|
||||
var e error
|
||||
schemaVersion, e = t.GenSchemaVersions(128)
|
||||
return e
|
||||
// To trigger full-reload instead of diff-reload, we need to increase the schema version
|
||||
// by at least `domain.LoadSchemaDiffVersionGapThreshold`.
|
||||
schemaVersion, e = t.GenSchemaVersions(64 + domain.LoadSchemaDiffVersionGapThreshold)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
// add the diff key so that the domain won't retry to reload the schemas with `schemaVersion` frequently.
|
||||
return t.SetSchemaDiff(&model.SchemaDiff{
|
||||
Version: schemaVersion,
|
||||
Type: model.ActionNone,
|
||||
SchemaID: -1,
|
||||
TableID: -1,
|
||||
RegenerateSchemaMap: true,
|
||||
})
|
||||
},
|
||||
); err != nil {
|
||||
return errors.Trace(err)
|
||||
|
||||
@ -96,6 +96,9 @@ import (
|
||||
|
||||
var (
|
||||
mdlCheckLookDuration = 50 * time.Millisecond
|
||||
|
||||
// LoadSchemaDiffVersionGapThreshold is the threshold for version gap to reload domain by loading schema diffs
|
||||
LoadSchemaDiffVersionGapThreshold int64 = 100
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -230,7 +233,7 @@ func (do *Domain) loadInfoSchema(startTS uint64) (infoschema.InfoSchema, bool, i
|
||||
// 3. There are less 100 diffs.
|
||||
// 4. No regenrated schema diff.
|
||||
startTime := time.Now()
|
||||
if currentSchemaVersion != 0 && neededSchemaVersion > currentSchemaVersion && neededSchemaVersion-currentSchemaVersion < 100 {
|
||||
if currentSchemaVersion != 0 && neededSchemaVersion > currentSchemaVersion && neededSchemaVersion-currentSchemaVersion < LoadSchemaDiffVersionGapThreshold {
|
||||
is, relatedChanges, err := do.tryLoadSchemaDiffs(m, currentSchemaVersion, neededSchemaVersion)
|
||||
if err == nil {
|
||||
do.infoCache.Insert(is, uint64(schemaTs))
|
||||
@ -415,13 +418,13 @@ func (do *Domain) tryLoadSchemaDiffs(m *meta.Meta, usedVersion, newVersion int64
|
||||
phyTblIDs := make([]int64, 0, len(diffs))
|
||||
actions := make([]uint64, 0, len(diffs))
|
||||
for _, diff := range diffs {
|
||||
if diff.RegenerateSchemaMap {
|
||||
return nil, nil, errors.Errorf("Meets a schema diff with RegenerateSchemaMap flag")
|
||||
}
|
||||
IDs, err := builder.ApplyDiff(m, diff)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if diff.RegenerateSchemaMap {
|
||||
return nil, nil, errors.Errorf("Meets a schema diff with RegenerateSchemaMap flag")
|
||||
}
|
||||
if canSkipSchemaCheckerDDL(diff.Type) {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user