Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table/tables: make CI TestCacheTableBasicReadAndWrite more stable #30924

Merged
merged 7 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import (
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/plancodec"
"github.com/pingcap/tidb/util/set"
"go.uber.org/zap"
"golang.org/x/sync/singleflight"
)

const (
Expand Down Expand Up @@ -4207,10 +4209,14 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
if r := recover(); r != nil {
}
}()
err := cachedTable.UpdateLockForRead(ctx, store, startTS)
if err != nil {
log.Warn("Update Lock Info Error")
}
_, err, _ := sf.Do(fmt.Sprintf("%d", tableInfo.ID), func() (interface{}, error) {
err := cachedTable.UpdateLockForRead(ctx, store, startTS)
if err != nil {
log.Warn("Update Lock Info Error", zap.Error(err))
}
return nil, nil
})
terror.Log(err)
}()
}
}
Expand Down Expand Up @@ -4238,6 +4244,8 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
return result, nil
}

var sf singleflight.Group

func (b *PlanBuilder) timeRangeForSummaryTable() QueryTimeRange {
const defaultSummaryDuration = 30 * time.Minute
hints := b.TableHints()
Expand Down
2 changes: 2 additions & 0 deletions table/tables/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ func TestCacheTableBasicReadAndWrite(t *testing.T) {
if tk.HasPlan("select * from write_tmp1", "UnionScan") {
break
}
// Wait for the cache to be loaded.
time.Sleep(50 * time.Millisecond)
lcwangchao marked this conversation as resolved.
Show resolved Hide resolved
}
require.True(t, i < 10)

Expand Down