Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/golang.org/x/tools-0…
Browse files Browse the repository at this point in the history
….9.1
  • Loading branch information
hawkingrei committed May 15, 2023
2 parents 33168f2 + fe11de8 commit 8e852ab
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 43 deletions.
8 changes: 4 additions & 4 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5983,8 +5983,8 @@ def go_deps():
name = "org_golang_x_crypto",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/crypto",
sum = "h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=",
version = "v0.8.0",
sum = "h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=",
version = "v0.9.0",
)
go_repository(
name = "org_golang_x_exp",
Expand Down Expand Up @@ -6040,8 +6040,8 @@ def go_deps():
name = "org_golang_x_oauth2",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/oauth2",
sum = "h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=",
version = "v0.7.0",
sum = "h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=",
version = "v0.8.0",
)
go_repository(
name = "org_golang_x_sync",
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ bazel_build: bazel_ci_prepare
cp bazel-out/k8-fastbuild/bin/tidb-server/tidb-server_/tidb-server ./bin
cp bazel-out/k8-fastbuild/bin/cmd/importer/importer_/importer ./bin
cp bazel-out/k8-fastbuild/bin/tidb-server/tidb-server-check_/tidb-server-check ./bin
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//tidb-server:tidb-server --stamp --workspace_status_command=./build/print-enterprise-workspace-status.sh --define gotags=enterprise
./bazel-out/k8-fastbuild/bin/tidb-server/tidb-server_/tidb-server -V

bazel_fail_build: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
Expand Down
42 changes: 42 additions & 0 deletions build/print-enterprise-workspace-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#
# Copyright 2023 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.

# This test is used to test compatible for BR restore.
# It will download backup data from internal file server.
# And make sure these backup data can restore through newly BR tools to newly cluster.

set -o errexit
set -o nounset
set -o pipefail

TiDB_RELEASE_VERSION=$(git describe --tags --dirty --always)
TiDB_BUILD_UTCTIME=$(date -u '+%Y-%m-%d %H:%M:%S')
TIDB_GIT_HASH=$(git rev-parse HEAD)
TIDB_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
TIDB_EDITION=${TIDB_EDITION:-Enterprise}
TIDB_ENTERPRISE_EXTENSION_GIT_HASH=""
if [ -a "extension/enterprise/.git" ]; then
TIDB_ENTERPRISE_EXTENSION_GIT_HASH=$(cd extension/enterprise && git rev-parse HEAD)
fi

cat <<EOF
STABLE_TiDB_RELEASE_VERSION ${TiDB_RELEASE_VERSION}
STABLE_TiDB_BUILD_UTCTIME ${TiDB_BUILD_UTCTIME}
STABLE_TIDB_GIT_HASH ${TIDB_GIT_HASH}
STABLE_TIDB_GIT_BRANCH ${TIDB_GIT_BRANCH}
STABLE_TIDB_EDITION ${TIDB_EDITION}
STABLE_TIDB_ENTERPRISE_EXTENSION_GIT_HASH ${TIDB_ENTERPRISE_EXTENSION_GIT_HASH}
EOF
3 changes: 2 additions & 1 deletion ddl/metadatalocktest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ go_test(
"mdl_test.go",
],
flaky = True,
shard_count = 31,
shard_count = 32,
deps = [
"//config",
"//ddl",
"//errno",
"//server",
"//testkit",
"//testkit/testsetup",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@org_uber_go_goleak//:goleak",
],
Expand Down
16 changes: 16 additions & 0 deletions ddl/metadatalocktest/mdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"
"time"

"github.com/pingcap/failpoint"
mysql "github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/server"
"github.com/pingcap/tidb/testkit"
Expand Down Expand Up @@ -1165,3 +1166,18 @@ func TestMDLPrepareFail(t *testing.T) {

tk2.MustExec("alter table test.t add column c int")
}

func TestMDLUpdateEtcdFail(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a int);")

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/ddl/mockUpdateMDLToETCDError", `3*return(true)`))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/ddl/mockUpdateMDLToETCDError"))
}()

tk.MustExec("alter table test.t add column c int")
}
5 changes: 5 additions & 0 deletions ddl/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func (s *MockSchemaSyncer) WatchGlobalSchemaVer(context.Context) {}

// UpdateSelfVersion implements SchemaSyncer.UpdateSelfVersion interface.
func (s *MockSchemaSyncer) UpdateSelfVersion(ctx context.Context, jobID int64, version int64) error {
failpoint.Inject("mockUpdateMDLToETCDError", func(val failpoint.Value) {
if val.(bool) {
failpoint.Return(errors.New("mock update mdl to etcd error"))
}
})
if variable.EnableMDL.Load() {
s.mdlSchemaVersions.Store(jobID, version)
} else {
Expand Down
2 changes: 1 addition & 1 deletion ddl/resourcegrouptest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go_test(
srcs = ["resource_group_test.go"],
flaky = True,
race = "on",
shard_count = 4,
shard_count = 5,
deps = [
"//ddl/internal/callback",
"//ddl/resourcegroup",
Expand Down
45 changes: 33 additions & 12 deletions ddl/resourcegrouptest/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ func TestResourceGroupBasic(t *testing.T) {

tk.MustExec("create resource group y RU_PER_SEC=4000")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
require.Equal(t, true, groupInfo.ID != 0)
require.Equal(t, "y", groupInfo.Name.L)
require.Equal(t, groupID.Load(), groupInfo.ID)
require.Equal(t, uint64(4000), groupInfo.RURate)
require.Equal(t, int64(4000), groupInfo.BurstLimit)
re.Equal(true, groupInfo.ID != 0)
re.Equal("y", groupInfo.Name.L)
re.Equal(groupID.Load(), groupInfo.ID)
re.Equal(uint64(4000), groupInfo.RURate)
re.Equal(int64(4000), groupInfo.BurstLimit)
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustExec("alter resource group y BURSTABLE RU_PER_SEC=5000")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
require.Equal(t, true, groupInfo.ID != 0)
require.Equal(t, "y", groupInfo.Name.L)
require.Equal(t, groupID.Load(), groupInfo.ID)
require.Equal(t, uint64(5000), groupInfo.RURate)
require.Equal(t, int64(-1), groupInfo.BurstLimit)
re.Equal(true, groupInfo.ID != 0)
re.Equal("y", groupInfo.Name.L)
re.Equal(groupID.Load(), groupInfo.ID)
re.Equal(uint64(5000), groupInfo.RURate)
re.Equal(int64(-1), groupInfo.BurstLimit)
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
Expand All @@ -142,8 +142,8 @@ func TestResourceGroupBasic(t *testing.T) {
tk.MustGetErrCode("create resource group x burstable, ru_per_sec=1000, burstable", mysql.ErrParse)
tk.MustContainErrMsg("create resource group x burstable, ru_per_sec=1000, burstable", "Dupliated options specified")
groups, err := infosync.ListResourceGroups(context.TODO())
require.Equal(t, 1, len(groups))
require.NoError(t, err)
re.Equal(1, len(groups))
re.NoError(err)

// Check information schema table information_schema.resource_groups
tk.MustExec("create resource group x RU_PER_SEC=1000 PRIORITY=LOW")
Expand Down Expand Up @@ -345,3 +345,24 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
}
}
}

func TestBindHints(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
re := require.New(t)

tk.MustExec("drop resource group if exists rg1")
tk.MustExec("create resource group rg1 RU_PER_SEC=1000")

tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")

tk.MustExec("create global binding for select * from t using select /*+ resource_group(rg1) */ * from t")
tk.MustQuery("select * from t")
re.Equal("rg1", tk.Session().GetSessionVars().StmtCtx.ResourceGroup)
re.Equal("", tk.Session().GetSessionVars().ResourceGroupName)
tk.MustQuery("select a, b from t")
re.Equal("", tk.Session().GetSessionVars().StmtCtx.ResourceGroup)
re.Equal("", tk.Session().GetSessionVars().ResourceGroupName)
}
1 change: 1 addition & 0 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ func (do *Domain) mdlCheckLoop() {
logutil.BgLogger().Info("mdl gets lock, update to owner", zap.Int64("jobID", jobID), zap.Int64("version", ver))
err := do.ddl.SchemaSyncer().UpdateSelfVersion(context.Background(), jobID, ver)
if err != nil {
jobNeedToSync = true
logutil.BgLogger().Warn("update self version failed", zap.Error(err))
} else {
jobCache[jobID] = ver
Expand Down
2 changes: 1 addition & 1 deletion extension/enterprise
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ require (
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20221023144134-a1e5550cf13e
golang.org/x/net v0.10.0
golang.org/x/oauth2 v0.7.0
golang.org/x/oauth2 v0.8.0
golang.org/x/sync v0.2.0
golang.org/x/sys v0.8.0
golang.org/x/term v0.8.0
Expand Down Expand Up @@ -268,7 +268,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v0.20.0 // indirect
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1227,8 +1227,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=
golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
1 change: 1 addition & 0 deletions planner/core/issuetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 3,
deps = [
"//parser",
"//planner",
Expand Down
14 changes: 14 additions & 0 deletions planner/core/issuetest/planner_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,17 @@ func TestIssue43461(t *testing.T) {

require.NotEqual(t, is.Columns, ts.Columns)
}

func TestIssue43645(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("CREATE TABLE t1(id int,col1 varchar(10),col2 varchar(10),col3 varchar(10));")
tk.MustExec("CREATE TABLE t2(id int,col1 varchar(10),col2 varchar(10),col3 varchar(10));")
tk.MustExec("INSERT INTO t1 values(1,NULL,NULL,null),(2,NULL,NULL,null),(3,NULL,NULL,null);")
tk.MustExec("INSERT INTO t2 values(1,'a','aa','aaa'),(2,'b','bb','bbb'),(3,'c','cc','ccc');")

rs := tk.MustQuery("WITH tmp AS (SELECT t2.* FROM t2) select (SELECT tmp.col1 FROM tmp WHERE tmp.id=t1.id ) col1, (SELECT tmp.col2 FROM tmp WHERE tmp.id=t1.id ) col2, (SELECT tmp.col3 FROM tmp WHERE tmp.id=t1.id ) col3 from t1;")
rs.Sort().Check(testkit.Rows("a aa aaa", "b bb bbb", "c cc ccc"))
}
19 changes: 16 additions & 3 deletions planner/core/rule_predicate_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,13 +988,26 @@ func (p *LogicalCTE) PredicatePushDown(predicates []expression.Expression, _ *lo
if !p.isOuterMostCTE {
return predicates, p.self
}
if len(predicates) == 0 {
pushedPredicates := make([]expression.Expression, len(predicates))
copy(pushedPredicates, predicates)
// The filter might change the correlated status of the cte.
// We forbid the push down that makes the change for now.
// Will support it later.
if !p.cte.IsInApply {
for i := len(pushedPredicates) - 1; i >= 0; i-- {
if len(expression.ExtractCorColumns(pushedPredicates[i])) == 0 {
continue
}
pushedPredicates = append(pushedPredicates[0:i], pushedPredicates[i+1:]...)
}
}
if len(pushedPredicates) == 0 {
p.cte.pushDownPredicates = append(p.cte.pushDownPredicates, expression.NewOne())
return predicates, p.self
}
newPred := make([]expression.Expression, 0, len(predicates))
for i := range predicates {
newPred = append(newPred, predicates[i].Clone())
for i := range pushedPredicates {
newPred = append(newPred, pushedPredicates[i].Clone())
ResolveExprAndReplace(newPred[i], p.cte.ColumnMap)
}
p.cte.pushDownPredicates = append(p.cte.pushDownPredicates, expression.ComposeCNFCondition(p.ctx, newPred...))
Expand Down
23 changes: 12 additions & 11 deletions planner/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,6 @@ func Optimize(ctx context.Context, sctx sessionctx.Context, node ast.Node, is in
}
}

// Override the resource group if necessary
// TODO: we didn't check the existence of the hinted resource group now to save the cost per query
if originStmtHints.HasResourceGroup {
if variable.EnableResourceControl.Load() {
sessVars.ResourceGroupName = originStmtHints.ResourceGroup
} else {
err := infoschema.ErrResourceGroupSupportDisabled
sessVars.StmtCtx.AppendWarning(err)
}
}

txnManger := sessiontxn.GetTxnManager(sctx)
if _, isolationReadContainTiKV := sessVars.IsolationReadEngines[kv.TiKV]; isolationReadContainTiKV {
var fp core.Plan
Expand Down Expand Up @@ -315,6 +304,18 @@ func Optimize(ctx context.Context, sctx sessionctx.Context, node ast.Node, is in
// Restore the hint to avoid changing the stmt node.
hint.BindHint(stmtNode, originHints)
}

// Override the resource group if necessary
// TODO: we didn't check the existence of the hinted resource group now to save the cost per query
if sessVars.StmtCtx.StmtHints.HasResourceGroup {
if variable.EnableResourceControl.Load() {
sessVars.ResourceGroupName = sessVars.StmtCtx.StmtHints.ResourceGroup
} else {
err := infoschema.ErrResourceGroupSupportDisabled
sessVars.StmtCtx.AppendWarning(err)
}
}

if sessVars.StmtCtx.EnableOptimizerDebugTrace && bestPlanFromBind != nil {
core.DebugTraceBestBinding(sctx, chosenBinding.Hint)
}
Expand Down
2 changes: 1 addition & 1 deletion server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ func TestAuthSessionTokenPlugin(t *testing.T) {
tk1.MustQuery("show session_states")

// create a token with TLS
cc.tlsConn = &tls.Conn{}
cc.tlsConn = tls.Client(nil, &tls.Config{})
tc.Session.GetSessionVars().ConnectionInfo = cc.connectInfo()
tk1.Session().Auth(&auth.UserIdentity{Username: "auth_session_token", Hostname: "localhost"}, nil, nil, nil)
tk1.MustQuery("show session_states")
Expand Down
16 changes: 15 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,24 @@ func (s *Server) onConn(conn *clientConn) {

func (cc *clientConn) connectInfo() *variable.ConnectionInfo {
connType := variable.ConnTypeSocket
sslVersion := ""
if cc.isUnixSocket {
connType = variable.ConnTypeUnixSocket
} else if cc.tlsConn != nil {
connType = variable.ConnTypeTLS
sslVersionNum := cc.tlsConn.ConnectionState().Version
switch sslVersionNum {
case tls.VersionTLS10:
sslVersion = "TLSv1.0"
case tls.VersionTLS11:
sslVersion = "TLSv1.1"
case tls.VersionTLS12:
sslVersion = "TLSv1.2"
case tls.VersionTLS13:
sslVersion = "TLSv1.3"
default:
sslVersion = fmt.Sprintf("Unknown TLS version: %d", sslVersionNum)
}
}
connInfo := &variable.ConnectionInfo{
ConnectionID: cc.connectionID,
Expand All @@ -712,7 +726,7 @@ func (cc *clientConn) connectInfo() *variable.ConnectionInfo {
ServerOSLoginUser: osUser,
OSVersion: osVersion,
ServerVersion: mysql.TiDBReleaseVersion,
SSLVersion: "v1.2.0", // for current go version
SSLVersion: sslVersion,
PID: serverPID,
DB: cc.dbname,
}
Expand Down

0 comments on commit 8e852ab

Please sign in to comment.