Skip to content

Commit

Permalink
Merge branch 'master' into stream-iters
Browse files Browse the repository at this point in the history
  • Loading branch information
joccau authored Oct 28, 2022
2 parents 27f8e0e + 636a363 commit 547d879
Show file tree
Hide file tree
Showing 399 changed files with 23,683 additions and 14,468 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
startup --host_jvm_args=-Xmx6g
startup --host_jvm_args=-Xmx5g
startup --unlimit_coredumps

run:ci --color=yes
Expand Down
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git/
bazel-bin/
bazel-out/
bazel-tidb/
bazel-testlogs/
bin/
tidb-server/tidb-server
*.test.bin
cmd/
Dockerfile
1 change: 1 addition & 0 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ header:
- "docs/"
- "br/"
- ".gitignore"
- ".dockerignore"
- ".gitattributes"
- ".cilinter.yaml"
- ".golangci.yml"
Expand Down
43 changes: 29 additions & 14 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def go_deps():
sum = "h1:zeZSRqj5yCg28tCkIV/z/lWbwvNm5qnKVS15PI8nhD0=",
version = "v0.1.0",
)
go_repository(
name = "com_github_acarl005_stripansi",
build_file_proto_mode = "disable",
importpath = "github.com/acarl005/stripansi",
sum = "h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=",
version = "v0.0.0-20180116102854-5a71ef0e047d",
)

go_repository(
name = "com_github_ajg_form",
Expand Down Expand Up @@ -2818,15 +2825,15 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:ceg4xjEEXNgPsScTQ5dtidiltLF4h17Y/jUqfyLAy9E=",
version = "v0.0.0-20220929075948-06e08d5ed64c",
sum = "h1:McYxPhA8SHqfUtLfQHHN0fQl4dy93IkhlX4Pp2MKIFA=",
version = "v0.0.0-20221014081430-26e28e6a281a",
)
go_repository(
name = "com_github_pingcap_log",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/log",
sum = "h1:ELiPxACz7vdo1qAvvaWJg1NrYFoY6gqAh/+Uo6aXdD8=",
version = "v1.1.0",
sum = "h1:URLoJ61DmmY++Sa/yyPEQHG2s/ZBeV1FbIswHEMrdoY=",
version = "v1.1.1-0.20221015072633-39906604fb81",
)
go_repository(
name = "com_github_pingcap_sysutil",
Expand All @@ -2839,8 +2846,8 @@ def go_deps():
name = "com_github_pingcap_tipb",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/tipb",
sum = "h1:kWYridgsn8xSKYJ2EkXp7uj5HwJnG5snpY3XP8oYmPU=",
version = "v0.0.0-20220824081009-0714a57aff1d",
sum = "h1:Yoo8j5xQGxjlsC3yt0ndsiAz0WZXED9rzsKmEN0U0DY=",
version = "v0.0.0-20221020071514-cd933387bcb5",
)
go_repository(
name = "com_github_pkg_browser",
Expand Down Expand Up @@ -3205,8 +3212,8 @@ def go_deps():
name = "com_github_shurcool_vfsgen",
build_file_proto_mode = "disable_global",
importpath = "github.com/shurcooL/vfsgen",
sum = "h1:y0cMJ0qjii33BnD6tMGcF/+gHYsoKQ6tbwQpy233OII=",
version = "v0.0.0-20180711163814-62bca832be04",
sum = "h1:ug7PpSOB5RBPK1Kg6qskGBoP3Vnj/aNYFTznWvlkGo0=",
version = "v0.0.0-20181202132449-6a9ea43bcacd",
)
go_repository(
name = "com_github_sirupsen_logrus",
Expand Down Expand Up @@ -3422,8 +3429,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:/13jzD/AR7v3dCLweFQ2JG8bihh3HLVIci2tbOHHGW0=",
version = "v2.0.1-0.20221012074856-6def8d7b90c4",
sum = "h1:5KLqhDGLc/mtemdS/odfOP717rn8ttsTj3jzZ8TZn9A=",
version = "v2.0.1-0.20221017092635-91be9c6ce6c0",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down Expand Up @@ -3584,12 +3591,20 @@ def go_deps():
sum = "h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=",
version = "v0.0.0-20161114210144-ceec8f93295a",
)
go_repository(
name = "com_github_vbauerster_mpb_v7",
build_file_proto_mode = "disable",
importpath = "github.com/vbauerster/mpb/v7",
sum = "h1:BkGfmb6nMrrBQDFECR/Q7RkKCw7ylMetCb4079CGs4w=",
version = "v7.5.3",
)

go_repository(
name = "com_github_vividcortex_ewma",
build_file_proto_mode = "disable_global",
importpath = "github.com/VividCortex/ewma",
sum = "h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=",
version = "v1.1.1",
sum = "h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=",
version = "v1.2.0",
)
go_repository(
name = "com_github_wangjohn_quickselect",
Expand Down Expand Up @@ -4489,6 +4504,6 @@ def go_deps():
name = "org_uber_go_zap",
build_file_proto_mode = "disable_global",
importpath = "go.uber.org/zap",
sum = "h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=",
version = "v1.21.0",
sum = "h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=",
version = "v1.23.0",
)
46 changes: 10 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 PingCAP, Inc.
# Copyright 2022 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,45 +13,19 @@
# limitations under the License.

# Builder image
FROM golang:1.19.1-alpine as builder
FROM alpine:edge as builder

RUN apk add --no-cache \
wget \
make \
git \
gcc \
binutils-gold \
musl-dev
ADD . https://raw.githubusercontent.com/njhallett/apk-fastest-mirror/c4ca44caef3385d830fea34df2dbc2ba4a17e021/apk-fastest-mirror.sh ./proxy
RUN sh ./proxy/apk-fastest-mirror.sh -t 50 && apk add --no-cache git build-base go

RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 \
&& chmod +x /usr/local/bin/dumb-init
COPY . /tidb
ARG GOPROXY
RUN export GOPROXY=${GOPROXY} && cd /tidb && make server

RUN mkdir -p /go/src/github.com/pingcap/tidb
WORKDIR /go/src/github.com/pingcap/tidb
FROM alpine:latest

# Cache dependencies
COPY go.mod .
COPY go.sum .
COPY parser/go.mod parser/go.mod
COPY parser/go.sum parser/go.sum

RUN GO111MODULE=on go mod download

# Build real binaries
COPY . .
RUN make

# Executable image
FROM alpine

RUN apk add --no-cache \
curl

COPY --from=builder /go/src/github.com/pingcap/tidb/bin/tidb-server /tidb-server
COPY --from=builder /usr/local/bin/dumb-init /usr/local/bin/dumb-init
COPY --from=builder /tidb/bin/tidb-server /tidb-server

WORKDIR /

EXPOSE 4000

ENTRYPOINT ["/usr/local/bin/dumb-init", "/tidb-server"]
ENTRYPOINT ["/tidb-server"]
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,30 @@ race: failpoint-enable

server:
ifeq ($(TARGET), "")
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server ./tidb-server
else
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./tidb-server
endif

server_debug:
ifeq ($(TARGET), "")
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server-debug tidb-server/main.go
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server-debug ./tidb-server
else
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./tidb-server
endif

server_check:
ifeq ($(TARGET), "")
$(GOBUILD) $(RACE_FLAG) -ldflags '$(CHECK_LDFLAGS)' -o bin/tidb-server tidb-server/main.go
$(GOBUILD) $(RACE_FLAG) -ldflags '$(CHECK_LDFLAGS)' -o bin/tidb-server ./tidb-server
else
$(GOBUILD) $(RACE_FLAG) -ldflags '$(CHECK_LDFLAGS)' -o '$(TARGET)' tidb-server/main.go
$(GOBUILD) $(RACE_FLAG) -ldflags '$(CHECK_LDFLAGS)' -o '$(TARGET)' ./tidb-server
endif

linux:
ifeq ($(TARGET), "")
GOOS=linux $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server-linux tidb-server/main.go
GOOS=linux $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server-linux ./tidb-server
else
GOOS=linux $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
GOOS=linux $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./tidb-server
endif

server_coverage:
Expand Down Expand Up @@ -461,3 +461,9 @@ bazel_addindextest: failpoint-enable bazel_ci_prepare

bazel_lint: bazel_prepare
bazel build //... --//build:with_nogo_flag=true

docker:
docker build -t "$(DOCKERPREFIX)tidb:latest" --build-arg 'GOPROXY=$(shell go env GOPROXY),' -f Dockerfile .

docker-test:
docker buildx build --platform linux/amd64,linux/arm64 --push -t "$(DOCKERPREFIX)tidb:latest" --build-arg 'GOPROXY=$(shell go env GOPROXY),' -f Dockerfile .
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ DUMPLING_GOTEST := CGO_ENABLED=1 GO111MODULE=on go test -ldflags '$(DUMPLING_LD
TEST_COVERAGE_DIR := "test_coverage"

ifneq ("$(CI)", "0")
BAZEL_GLOBAL_CONFIG := --output_user_root=/home/jenkins/.tidb/tmp
BAZEL_GLOBAL_CONFIG := --output_user_root=/home/jenkins/.tidb/tmp --host_jvm_args=-XX:+UnlockExperimentalVMOptions --host_jvm_args=-XX:+UseZGC
BAZEL_CMD_CONFIG := --config=ci --repository_cache=/home/jenkins/.tidb/tmp
endif
26 changes: 21 additions & 5 deletions br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,17 @@ func (bc *Client) GetStorage() storage.ExternalStorage {
return bc.storage
}

// SetStorage set ExternalStorage for client.
func (bc *Client) SetStorage(ctx context.Context, backend *backuppb.StorageBackend, opts *storage.ExternalStorageOptions) error {
var err error
bc.storage, err = storage.New(ctx, backend, opts)
// SetStorageAndCheckNotInUse sets ExternalStorage for client and check storage not in used by others.
func (bc *Client) SetStorageAndCheckNotInUse(
ctx context.Context,
backend *backuppb.StorageBackend,
opts *storage.ExternalStorageOptions,
) error {
err := bc.SetStorage(ctx, backend, opts)
if err != nil {
return errors.Trace(err)
}

// backupmeta already exists
exist, err := bc.storage.FileExists(ctx, metautil.MetaFile)
if err != nil {
Expand All @@ -204,10 +208,22 @@ func (bc *Client) SetStorage(ctx context.Context, backend *backuppb.StorageBacke
if err != nil {
return err
}
bc.backend = backend
return nil
}

// SetStorage sets ExternalStorage for client.
func (bc *Client) SetStorage(
ctx context.Context,
backend *backuppb.StorageBackend,
opts *storage.ExternalStorageOptions,
) error {
var err error

bc.backend = backend
bc.storage, err = storage.New(ctx, backend, opts)
return errors.Trace(err)
}

// GetClusterID returns the cluster ID of the tidb cluster to backup.
func (bc *Client) GetClusterID() uint64 {
return bc.clusterID
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (s *schemaInfo) calculateChecksum(

func (s *schemaInfo) dumpStatsToJSON(statsHandle *handle.Handle) error {
jsonTable, err := statsHandle.DumpStatsToJSON(
s.dbInfo.Name.String(), s.tableInfo, nil)
s.dbInfo.Name.String(), s.tableInfo, nil, true)
if err != nil {
return errors.Trace(err)
}
Expand Down
8 changes: 5 additions & 3 deletions br/pkg/glue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ go_library(
srcs = [
"console_glue.go",
"glue.go",
"progressing.go",
],
importpath = "github.com/pingcap/tidb/br/pkg/glue",
visibility = ["//visibility:public"],
deps = [
"//br/pkg/logutil",
"//br/pkg/utils",
"//ddl",
"//domain",
"//kv",
"//parser/model",
"//sessionctx",
"@com_github_fatih_color//:color",
"@com_github_pingcap_log//:log",
"@com_github_tikv_pd_client//:client",
"@com_github_vbauerster_mpb_v7//:mpb",
"@com_github_vbauerster_mpb_v7//decor",
"@org_golang_x_term//:term",
"@org_uber_go_zap//:zap",
],
)

Expand Down
Loading

0 comments on commit 547d879

Please sign in to comment.