Skip to content

Commit

Permalink
Merge branch 'master' into upgrade_bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Dec 12, 2022
2 parents 5cfa8b1 + c13dfe3 commit ba1d973
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ddl/concurrentddltest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "concurrentddltest_test",
timeout = "long",
timeout = "moderate",
srcs = [
"main_test.go",
"switch_test.go",
Expand Down
2 changes: 1 addition & 1 deletion domain/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// MockInfoCacheAndLoadInfoSchema only used in unit tests.
func (do *Domain) MockInfoCacheAndLoadInfoSchema(is infoschema.InfoSchema) {
do.infoCache = infoschema.NewCache(16)
do.infoCache.Reset(16)
do.infoCache.Insert(is, 0)
}

Expand Down
2 changes: 1 addition & 1 deletion executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ go_library(

go_test(
name = "executor_test",
timeout = "long",
timeout = "moderate",
srcs = [
"adapter_test.go",
"admin_test.go",
Expand Down
2 changes: 1 addition & 1 deletion executor/seqtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "seqtest_test",
timeout = "moderate",
timeout = "short",
srcs = [
"main_test.go",
"prepared_test.go",
Expand Down
11 changes: 9 additions & 2 deletions infoschema/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ type InfoCache struct {
}

// NewCache creates a new InfoCache.
func NewCache(capcity int) *InfoCache {
return &InfoCache{cache: make([]InfoSchema, 0, capcity)}
func NewCache(capacity int) *InfoCache {
return &InfoCache{cache: make([]InfoSchema, 0, capacity)}
}

// Reset resets the cache.
func (h *InfoCache) Reset(capacity int) {
h.mu.Lock()
defer h.mu.Unlock()
h.cache = make([]InfoSchema, 0, capacity)
}

// GetLatest gets the newest information schema.
Expand Down
6 changes: 3 additions & 3 deletions sessiontxn/staleread/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,18 @@ func TestStaleReadProcessorWithExecutePreparedStmt(t *testing.T) {
tk.MustExec("set @@tx_read_ts=''")

// `@@tidb_read_staleness`
tk.MustExec("set @@tidb_read_staleness=-5")
tk.MustExec("set @@tidb_read_staleness=-100")
processor = createProcessor(t, tk.Session())
err = processor.OnExecutePreparedStmt(nil)
require.True(t, processor.IsStaleness())
require.Equal(t, int64(0), processor.GetStalenessInfoSchema().SchemaMetaVersion())
expectedTS, err := staleread.CalculateTsWithReadStaleness(tk.Session(), -5*time.Second)
expectedTS, err := staleread.CalculateTsWithReadStaleness(tk.Session(), -100*time.Second)
require.NoError(t, err)
require.Equal(t, expectedTS, processor.GetStalenessReadTS())
tk.MustExec("set @@tidb_read_staleness=''")

// `@@tidb_read_staleness` will be ignored when `as of` or `@@tx_read_ts`
tk.MustExec("set @@tidb_read_staleness=-5")
tk.MustExec("set @@tidb_read_staleness=-100")
processor = createProcessor(t, tk.Session())
err = processor.OnExecutePreparedStmt(func(sctx sessionctx.Context) (uint64, error) {
return p1.ts, nil
Expand Down

0 comments on commit ba1d973

Please sign in to comment.