-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
bindinfo: add timeout for loading binding from storage #51550
Merged
ti-chi-bot
merged 18 commits into
pingcap:master
from
hawkingrei:add_timeout_for_load_binding
Mar 12, 2024
+785
−244
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
64387d9
bindinfo: add timeout for loading binding from storage
hawkingrei d7b6c22
bindinfo: add timeout for loading binding from storage
hawkingrei 471bfd7
update
hawkingrei b2c34c3
update
hawkingrei e43c3ba
update
hawkingrei 2e3a501
Update pkg/bindinfo/binding_cache.go
hawkingrei d588b08
update
hawkingrei b8da5da
update
hawkingrei eb86c86
update
hawkingrei c6ca703
update
hawkingrei 8d57fbe
update
hawkingrei 85fa14f
update
hawkingrei dbf2229
update
hawkingrei da14732
update
hawkingrei 5ab713d
linter
hawkingrei d390722
linter
hawkingrei bcb5de1
linter
hawkingrei d8c7622
linter
hawkingrei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_test") | ||
|
||
go_test( | ||
name = "timeout_test", | ||
timeout = "short", | ||
srcs = [ | ||
"main_test.go", | ||
"timeout_test.go", | ||
], | ||
flaky = True, | ||
deps = [ | ||
"//pkg/bindinfo", | ||
"//pkg/testkit", | ||
"//pkg/testkit/testsetup", | ||
"@org_uber_go_goleak//:goleak", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package timeout | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/testkit/testsetup" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testsetup.SetupForCommonTest() | ||
opts := []goleak.Option{ | ||
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), | ||
goleak.IgnoreTopFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"), | ||
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"), | ||
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"), | ||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), | ||
goleak.IgnoreTopFunction("time.Sleep"), | ||
} | ||
goleak.VerifyTestMain(m, opts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package timeout | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/bindinfo" | ||
"github.com/pingcap/tidb/pkg/testkit" | ||
) | ||
|
||
func TestFuzzyBindingHintsWithSourceReturningTimeout(t *testing.T) { | ||
store := testkit.CreateMockStore(t) | ||
tk := testkit.NewTestKit(t, store) | ||
tk.MustExec(`use test`) | ||
|
||
for _, db := range []string{"db1", "db2", "db3"} { | ||
tk.MustExec(`create database ` + db) | ||
tk.MustExec(`use ` + db) | ||
tk.MustExec(`create table t1 (a int, b int, c int, d int, key(a), key(b), key(c), key(d))`) | ||
tk.MustExec(`create table t2 (a int, b int, c int, d int, key(a), key(b), key(c), key(d))`) | ||
tk.MustExec(`create table t3 (a int, b int, c int, d int, key(a), key(b), key(c), key(d))`) | ||
} | ||
tk.MustExec(`set @@tidb_opt_enable_fuzzy_binding=1`) | ||
|
||
for _, c := range []struct { | ||
binding string | ||
qTemplate string | ||
}{ | ||
// use index | ||
{`create global binding using select /*+ use_index(t1, c) */ * from *.t1 where a=1`, | ||
`select * from %st1 where a=1000`}, | ||
} { | ||
tk.MustExec(c.binding) | ||
for _, currentDB := range []string{"db1", "db2", "db3"} { | ||
tk.MustExec(`use ` + currentDB) | ||
for _, db := range []string{"db1.", "db2.", "db3.", ""} { | ||
query := fmt.Sprintf(c.qTemplate, db) | ||
tk.MustExec(query) | ||
tk.MustQuery(`show warnings`).Check(testkit.Rows()) // no warning | ||
sctx := tk.Session() | ||
sctx.SetValue(bindinfo.GetBindingReturnNil, true) | ||
sctx.SetValue(bindinfo.GetBindingReturnNilAlways, true) | ||
sctx.SetValue(bindinfo.LoadBindingNothing, true) | ||
tk.MustExec(query) | ||
sctx.ClearValue(bindinfo.GetBindingReturnNil) | ||
sctx.ClearValue(bindinfo.GetBindingReturnNilAlways) | ||
sctx.ClearValue(bindinfo.LoadBindingNothing) | ||
tk.MustQuery(`select @@last_plan_from_binding`).Check(testkit.Rows("0")) | ||
bindinfo.GetBindingReturnNilBool.Store(false) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
means return binding, matched, nil at last?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, actually there have been no changes here.