Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into improve-sysvar-co…
Browse files Browse the repository at this point in the history
…verage

* upstream/master: (98 commits)
  planner: provide a unified interface to set and get user variables and types (pingcap#37046)
  *: fix check-2 to bazel (pingcap#37055)
  distsql: revert 37019 (pingcap#37048)
  planner: introduce new functions for the general statement in session interface (pingcap#37024)
  session: make BenchmarkCompileExecutePreparedStmt update to date (pingcap#36960)
  server: Change proxyprotocol to lazy mode (pingcap#36301)
  test: fix `TestDDLSchedulingMultiTimes` and `TestConcurrentDDLSwitch` timeout (pingcap#37043)
  makefile: add bazel realtikvtest (pingcap#37042)
  distsql: make analyze request SI (pingcap#37019)
  *: gofmt code for adapting go 1.19 (pingcap#36832)
  planner: fix data race in the TestInlineProjection4HashJoinIssue15316 (pingcap#37014)
  planner: introduce Session.CacheGeneralStmt for general plan cache (pingcap#37028)
  server: revise scheme code (pingcap#37021)
  planner: fix unstable test TestPushDownSelectionForMPP (pingcap#37038)
  executor: more precise memory tracking (pingcap#35785)
  executor: add privilege check for prepare stmt (pingcap#36933)
  *: optimize temptable.SessionSnapshotInterceptor (pingcap#36999)
  statistics: batch insert topn and buckets to storage to speed up loading stats (pingcap#36948)
  planner: remove keyword `prepared` in plan cache backend (pingcap#37023)
  util: fix unstable test TestCheckCN (pingcap#37016)
  ...
  • Loading branch information
morgo committed Aug 11, 2022
2 parents ae2bcc9 + 7d8c45a commit d71b97f
Show file tree
Hide file tree
Showing 403 changed files with 15,920 additions and 12,925 deletions.
20 changes: 20 additions & 0 deletions .cilinter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
run:
timeout: 10m
linters:
disable-all: true
enable:
- varcheck
- structcheck
- deadcode
- rowserrcheck
- prealloc

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
- rowserrcheck
- makezero

1 change: 1 addition & 0 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ header:
- 'br/'
- '.gitignore'
- '.gitattributes'
- '.cilinter.yaml'
- '.golangci.yml'
- '.golangci_br.yml'
- 'LICENSES/'
Expand Down
99 changes: 70 additions & 29 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def go_deps():
name = "co_honnef_go_tools",
build_file_proto_mode = "disable_global",
importpath = "honnef.co/go/tools",
replace = "honnef.co/go/tools",
sum = "h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=",
version = "v0.3.3",
)
Expand Down Expand Up @@ -85,8 +84,8 @@ def go_deps():
name = "com_github_alingse_asasalint",
build_file_proto_mode = "disable",
importpath = "github.com/alingse/asasalint",
sum = "h1:qqGPDTV0ff0tWHN/nnIlSdjlU/EwRPaUY4SfpE1rnms=",
version = "v0.0.10",
sum = "h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw=",
version = "v0.0.11",
)

go_repository(
Expand Down Expand Up @@ -282,8 +281,8 @@ def go_deps():
name = "com_github_blacktear23_go_proxyprotocol",
build_file_proto_mode = "disable_global",
importpath = "github.com/blacktear23/go-proxyprotocol",
sum = "h1:WmMmtZanGEfIHnJN9N3A4Pl6mM69D+GxEph2eOaCf7g=",
version = "v1.0.0",
sum = "h1:zR7PZeoU0wAkElcIXenFiy3R56WB6A+UEVi4c6RH8wo=",
version = "v1.0.2",
)
go_repository(
name = "com_github_blizzy78_varnamelen",
Expand Down Expand Up @@ -318,8 +317,8 @@ def go_deps():
name = "com_github_burntsushi_toml",
build_file_proto_mode = "disable_global",
importpath = "github.com/BurntSushi/toml",
sum = "h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=",
version = "v1.1.0",
sum = "h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=",
version = "v1.2.0",
)
go_repository(
name = "com_github_burntsushi_xgb",
Expand Down Expand Up @@ -672,8 +671,8 @@ def go_deps():
name = "com_github_daixiang0_gci",
build_file_proto_mode = "disable",
importpath = "github.com/daixiang0/gci",
sum = "h1:wf7x0xRjQqTlA2dzHTI0A/xPyp7VcBatBG9nwGatwbQ=",
version = "v0.4.3",
sum = "h1:3+Z8nb/4dhJQYjpEbG4wt5na+KFJJTZ++PVEq/MVKX4=",
version = "v0.5.0",
)

go_repository(
Expand Down Expand Up @@ -982,8 +981,8 @@ def go_deps():
name = "com_github_gaijinentertainment_go_exhaustruct_v2",
build_file_proto_mode = "disable",
importpath = "github.com/GaijinEntertainment/go-exhaustruct/v2",
sum = "h1:V9xVvhKbLt7unNEGAruK1xXglyc668Pq3Xx0MNTNqpo=",
version = "v2.2.0",
sum = "h1:DGdS4FlsdM6OkluXOhgkvwx05ZjD3Idm9WqtYnOmSuY=",
version = "v2.2.2",
)

go_repository(
Expand Down Expand Up @@ -1336,8 +1335,8 @@ def go_deps():
name = "com_github_golangci_golangci_lint",
build_file_proto_mode = "disable",
importpath = "github.com/golangci/golangci-lint",
sum = "h1:qvMDVv49Hrx3PSEXZ0bD/yhwSbhsOihQjFYCKieegIw=",
version = "v1.47.2",
sum = "h1:ri7A2DgtFpxgqcMSsU3qIT0IBm/SCdYgXlvmJx4szUU=",
version = "v1.47.3",
)
go_repository(
name = "com_github_golangci_gosec",
Expand Down Expand Up @@ -1569,6 +1568,13 @@ def go_deps():
sum = "h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3Uqrmrcpk=",
version = "v0.1.1",
)
go_repository(
name = "com_github_gostaticanalysis_testutil",
build_file_proto_mode = "disable",
importpath = "github.com/gostaticanalysis/testutil",
sum = "h1:d2/eIbH9XjD1fFwD5SHv8x168fjbQ9PB8hvs8DSEC08=",
version = "v0.3.1-0.20210208050101-bfb5c8eec0e4",
)

go_repository(
name = "com_github_grpc_ecosystem_go_grpc_middleware",
Expand Down Expand Up @@ -2642,6 +2648,27 @@ def go_deps():
sum = "h1:yXiysv1CSK7Q5yjGy1710zZGnsbMUIjluWBxtLXHPBo=",
version = "v0.1.6",
)
go_repository(
name = "com_github_otiai10_copy",
build_file_proto_mode = "disable",
importpath = "github.com/otiai10/copy",
sum = "h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=",
version = "v1.2.0",
)
go_repository(
name = "com_github_otiai10_curr",
build_file_proto_mode = "disable",
importpath = "github.com/otiai10/curr",
sum = "h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=",
version = "v1.0.0",
)
go_repository(
name = "com_github_otiai10_mint",
build_file_proto_mode = "disable",
importpath = "github.com/otiai10/mint",
sum = "h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc=",
version = "v1.3.1",
)

go_repository(
name = "com_github_pascaldekloe_goe",
Expand Down Expand Up @@ -2719,8 +2746,8 @@ def go_deps():
name = "com_github_pingcap_check",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/check",
sum = "h1:HVl5539r48eA+uDuX/ziBmQCxzT1pGrzWbKuXT46Bq0=",
version = "v0.0.0-20211026125417-57bd13f7b5f0",
sum = "h1:iRtOAQ6FXkY/BGvst3CDfTva4nTqh6CL8WXvanLdbu0=",
version = "v0.0.0-20191107115940-caf2b9e6ccf4",
)
go_repository(
name = "com_github_pingcap_errors",
Expand Down Expand Up @@ -2754,8 +2781,8 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:PAXtUVMJnyQQS8t9GzihIFmh6FBXu0JziWbIVknLniA=",
version = "v0.0.0-20220711062932-08b02befd813",
sum = "h1:4UQdx1acoUrQD0Q5Etz1ABd31duzSgp3XwEnb/cvV9I=",
version = "v0.0.0-20220804022843-f006036b1277",
)
go_repository(
name = "com_github_pingcap_log",
Expand Down Expand Up @@ -2976,8 +3003,8 @@ def go_deps():
name = "com_github_ryancurrah_gomodguard",
build_file_proto_mode = "disable",
importpath = "github.com/ryancurrah/gomodguard",
sum = "h1:ww2fsjqocGCAFamzvv/b8IsRduuHHeK2MHTcTxZTQX8=",
version = "v1.2.3",
sum = "h1:CpMSDKan0LtNGGhPrvupAoLeObRFjND8/tU1rEOtBp4=",
version = "v1.2.4",
)
go_repository(
name = "com_github_ryanrolds_sqlclosecheck",
Expand Down Expand Up @@ -3122,15 +3149,15 @@ def go_deps():
name = "com_github_shurcool_vfsgen",
build_file_proto_mode = "disable_global",
importpath = "github.com/shurcooL/vfsgen",
sum = "h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU=",
version = "v0.0.0-20200824052919-0d455de96546",
sum = "h1:y0cMJ0qjii33BnD6tMGcF/+gHYsoKQ6tbwQpy233OII=",
version = "v0.0.0-20180711163814-62bca832be04",
)
go_repository(
name = "com_github_sirupsen_logrus",
build_file_proto_mode = "disable_global",
importpath = "github.com/sirupsen/logrus",
sum = "h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=",
version = "v1.8.1",
sum = "h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=",
version = "v1.9.0",
)
go_repository(
name = "com_github_sivchari_containedctx",
Expand All @@ -3143,8 +3170,8 @@ def go_deps():
name = "com_github_sivchari_nosnakecase",
build_file_proto_mode = "disable",
importpath = "github.com/sivchari/nosnakecase",
sum = "h1:ZBvAu1H3uteN0KQ0IsLpIFOwYgPEhKLyv2ahrVkub6M=",
version = "v1.5.0",
sum = "h1:7QkpWIRMe8x25gckkFd2A5Pi6Ymo0qgr4JrhGt95do8=",
version = "v1.7.0",
)

go_repository(
Expand Down Expand Up @@ -3305,6 +3332,20 @@ def go_deps():
sum = "h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A=",
version = "v0.1.1",
)
go_repository(
name = "com_github_tenntenn_modver",
build_file_proto_mode = "disable",
importpath = "github.com/tenntenn/modver",
sum = "h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA=",
version = "v1.0.1",
)
go_repository(
name = "com_github_tenntenn_text_transform",
build_file_proto_mode = "disable",
importpath = "github.com/tenntenn/text/transform",
sum = "h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag=",
version = "v0.0.0-20200319021203-7eef512accb3",
)

go_repository(
name = "com_github_tetafro_godot",
Expand All @@ -3325,8 +3366,8 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:oCtRW/f0FZabdoLuvqxIewcmHR83RlsdN37dS0EBRTU=",
version = "v2.0.1-0.20220729034404-e10841f2d158",
sum = "h1:tugwRUqH0gYZ0noHr17AVSKxNVd+Jl2BmNqgANeDIok=",
version = "v2.0.1-0.20220809034808-2ed2113d1090",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down Expand Up @@ -3619,8 +3660,8 @@ def go_deps():
name = "com_gitlab_bosi_decorder",
build_file_proto_mode = "disable",
importpath = "gitlab.com/bosi/decorder",
sum = "h1:LRfb3lP6mZWjUzpMOCLTVjcnl/SqZWBWmKNqQvMocQs=",
version = "v0.2.2",
sum = "h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0=",
version = "v0.2.3",
)

go_repository(
Expand Down
78 changes: 53 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ dev: checklist check explaintest gogenerate br_unit_test test_part_parser_dev ut
@>&2 echo "Great, all tests passed."

# Install the check tools.
check-setup:tools/bin/revive tools/bin/goword
check-setup:tools/bin/revive

check: check-parallel lint tidy testSuite check-static errdoc
check: check-file-perm check-parallel lint tidy testSuite errdoc bazel_golangcilinter bazel_all_build

fmt:
@echo "gofmt (simplify)"
@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)

goword:tools/bin/goword
tools/bin/goword $(FILES) 2>&1 | $(FAIL_ON_STDOUT)

check-static: tools/bin/golangci-lint
GO111MODULE=on CGO_ENABLED=0 tools/bin/golangci-lint run -v $$($(PACKAGE_DIRECTORIES)) --config .golangci.yml

check-file-perm:
@echo "check file permission"
./tools/check/check-file-perm.sh

gogenerate:
@echo "go generate ./..."
./tools/check/check-gogenerate.sh
Expand Down Expand Up @@ -211,17 +212,17 @@ tools/bin/revive:
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/mgechev/[email protected]

tools/bin/failpoint-ctl:
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/pingcap/failpoint/failpoint-ctl@master
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/pingcap/failpoint/failpoint-ctl@2eaa328

tools/bin/errdoc-gen:
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/pingcap/errors/errdoc-gen@master
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/pingcap/errors/errdoc-gen@518f63d

tools/bin/golangci-lint:
# Build from source is not recommand. See https://golangci-lint.run/usage/install/
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/golangci/golangci-lint/cmd/[email protected]

tools/bin/vfsgendev:
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/shurcooL/vfsgen/cmd/vfsgendev@master
GOBIN=$(shell pwd)/tools/bin $(GO) install github.com/shurcooL/vfsgen/cmd/vfsgendev@0d455de

tools/bin/gotestsum:
GOBIN=$(shell pwd)/tools/bin $(GO) install gotest.tools/[email protected]
Expand Down Expand Up @@ -332,15 +333,6 @@ ifeq ("$(GOOS)", "freebsd")
GOBUILD = CGO_ENABLED=0 GO111MODULE=on go build -trimpath -ldflags '$(LDFLAGS)'
endif

br_coverage:
tools/bin/gocovmerge "$(TEST_DIR)"/cov.* | grep -vE ".*.pb.go|.*__failpoint_binding__.go" > "$(TEST_DIR)/all_cov.out"
ifeq ("$(JenkinsCI)", "1")
tools/bin/goveralls -coverprofile=$(TEST_DIR)/all_cov.out -service=jenkins-ci -repotoken $(COVERALLS_TOKEN)
else
go tool cover -html "$(TEST_DIR)/all_cov.out" -o "$(TEST_DIR)/all_cov.html"
grep -F '<option' "$(TEST_DIR)/all_cov.html"
endif

# TODO: adjust bins when br integraion tests reformat.
br_bins:
@which bin/tidb-server
Expand Down Expand Up @@ -394,39 +386,75 @@ generate_grafana_scripts:
@cd metrics/grafana && mv tidb_summary.json tidb_summary.json.committed && ./generate_json.sh && diff -u tidb_summary.json.committed tidb_summary.json && rm tidb_summary.json.committed

bazel_ci_prepare:
bazel --output_user_root=/home/jenkins/.tidb/tmp run --config=ci //:gazelle
bazel $(BAZEL_GLOBAL_CONFIG) run $(BAZEL_CMD_CONFIG) //:gazelle

bazel_prepare:
bazel run //:gazelle
bazel run //:gazelle
bazel run //:gazelle -- update-repos -from_file=go.mod -build_file_proto_mode=disable

bazel_test: failpoint-enable bazel_ci_prepare
bazel --output_user_root=/home/jenkins/.tidb/tmp test --config=ci \
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) \
-- //... -//cmd/... -//tests/graceshutdown/... \
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/task:task_test


bazel_coverage_test: failpoint-enable bazel_ci_prepare
bazel --output_user_root=/home/jenkins/.tidb/tmp coverage --config=ci --build_event_json_file=bazel_1.json --@io_bazel_rules_go//go/config:cover_format=go_cover \
bazel $(BAZEL_GLOBAL_CONFIG) coverage $(BAZEL_CMD_CONFIG) \
--build_event_json_file=bazel_1.json --@io_bazel_rules_go//go/config:cover_format=go_cover \
-- //... -//cmd/... -//tests/graceshutdown/... \
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/task:task_test
bazel --output_user_root=/home/jenkins/.tidb/tmp coverage --config=ci --build_event_json_file=bazel_2.json --@io_bazel_rules_go//go/config:cover_format=go_cover --define gotags=featuretag \
bazel $(BAZEL_GLOBAL_CONFIG) coverage $(BAZEL_CMD_CONFIG) \
--build_event_json_file=bazel_2.json --@io_bazel_rules_go//go/config:cover_format=go_cover --define gotags=featuretag \
-- //... -//cmd/... -//tests/graceshutdown/... \
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/task:task_test

bazel_all_build: bazel_ci_prepare
mkdir -p bin
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//... --//build:with_nogo_flag=true

bazel_build: bazel_ci_prepare
mkdir -p bin
bazel --output_user_root=/home/jenkins/.tidb/tmp build --config=ci //... --//build:with_nogo_flag=true
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//cmd/importer:importer //tidb-server:tidb-server //tidb-server:tidb-server-check --//build:with_nogo_flag=true
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_fail_build: failpoint-enable bazel_ci_prepare
bazel --output_user_root=/home/jenkins/.tidb/tmp build --config=ci //...
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//...

bazel_clean:
bazel --output_user_root=/home/jenkins/.tidb/tmp clean
bazel $(BAZEL_GLOBAL_CONFIG) clean

bazel_junit:
bazel_collect
@mkdir -p $(TEST_COVERAGE_DIR)
mv ./junit.xml `$(TEST_COVERAGE_DIR)/junit.xml`

bazel_golangcilinter:
bazel $(BAZEL_GLOBAL_CONFIG) run $(BAZEL_CMD_CONFIG) \
--run_under="cd $(CURDIR) && " \
@com_github_golangci_golangci_lint//cmd/golangci-lint:golangci-lint \
-- run $$($(PACKAGE_DIRECTORIES)) --config ./.cilinter.yaml

bazel_brietest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/brietest/...

bazel_pessimistictest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/pessimistictest/...

bazel_sessiontest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/sessiontest/...

bazel_statisticstest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/statisticstest/...

bazel_txntest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/txntest/...
Loading

0 comments on commit d71b97f

Please sign in to comment.