Skip to content

Commit

Permalink
*: support building infoschema V2, and introduce @@tidb_schema_cache_…
Browse files Browse the repository at this point in the history
…size (#51257)

close #51256
  • Loading branch information
tiancaiamao authored Feb 29, 2024
1 parent 8e7658d commit 0e8533c
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 133 deletions.
12 changes: 10 additions & 2 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,12 @@ func (do *Domain) loadInfoSchema(startTS uint64) (infoschema.InfoSchema, bool, i
// try to insert here as well to correct the schemaTs if previous is wrong
// the insert method check if schemaTs is zero
do.infoCache.Insert(is, uint64(schemaTs))
return is, true, 0, nil, nil

enableV2 := variable.SchemaCacheSize.Load() > 0
isV2 := infoschema.IsV2(is)
if enableV2 == isV2 {
return is, true, 0, nil, nil
}
}

currentSchemaVersion := int64(0)
Expand Down Expand Up @@ -448,7 +453,10 @@ func (do *Domain) tryLoadSchemaDiffs(m *meta.Meta, usedVersion, newVersion int64
}
diffs = append(diffs, diff)
}
builder := infoschema.NewBuilder(do, do.sysFacHack, do.infoCache.Data).InitWithOldInfoSchema(do.infoCache.GetLatest())
builder, err := infoschema.NewBuilder(do, do.sysFacHack, do.infoCache.Data).InitWithOldInfoSchema(do.infoCache.GetLatest())
if err != nil {
return nil, nil, nil, errors.Trace(err)
}
builder.SetDeltaUpdateBundles()
phyTblIDs := make([]int64, 0, len(diffs))
actions := make([]uint64, 0, len(diffs))
Expand Down
3 changes: 2 additions & 1 deletion pkg/infoschema/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ go_test(
],
embed = [":infoschema"],
flaky = True,
shard_count = 9,
shard_count = 10,
deps = [
"//pkg/ddl/placement",
"//pkg/domain",
Expand All @@ -88,6 +88,7 @@ go_test(
"//pkg/meta/autoid",
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/sessionctx/variable",
"//pkg/store/mockstore",
"//pkg/table",
"//pkg/testkit",
Expand Down
Loading

0 comments on commit 0e8533c

Please sign in to comment.