Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Merge master to release 3.1 #203

Merged
merged 58 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7cf307c
restore: fix alter auto increment id for no-primary-key table (#139)
5kbpers Jan 10, 2020
191fdce
*: use oracle package to manipulate ts and test gc safe point (#121)
overvenus Jan 15, 2020
2aa1322
cmd: convert version command to flags (#144)
overvenus Jan 16, 2020
0c1dea4
*: add changelog and github templates (#143)
overvenus Jan 16, 2020
0a43d2a
restore: merge tidb-tools/pkg/restore-util (#146)
overvenus Jan 22, 2020
3863a3a
Fixed handling for a dbName that do not exist in the backup being res…
Feb 1, 2020
6b65080
validate: fix debug meta test ci (#153)
3pointer Feb 5, 2020
0dfe82d
*: extracts runBackup/runRestore in cmd into pkg/task (#156)
kennytm Feb 10, 2020
8c97452
restore: fix restore summary log (#150)
3pointer Feb 13, 2020
008ec45
restore: enhance error handling (#152)
5kbpers Feb 13, 2020
1e1fc97
Incremental BR: support DDL (#155)
5kbpers Feb 20, 2020
4492b8f
Reduce TiDB dependencies (#158)
kennytm Feb 22, 2020
3c9d42f
go.mod: update tidb (#168)
overvenus Feb 23, 2020
028963d
BR support TLS (#161)
3pointer Feb 27, 2020
e462f80
upgrade golangci and prepare for go 1.14 (#171)
overvenus Feb 28, 2020
4657932
backup: add raw backup command (#101)
3pointer Mar 4, 2020
0a1a044
restore: speed up retry on not leader (#179)
overvenus Mar 5, 2020
09fb715
conn, restore: paginate scan regions (#165)
overvenus Mar 5, 2020
82b5016
Batch restore (#167)
overvenus Mar 6, 2020
3fc9ee2
README, docker: add quick start (#181)
overvenus Mar 7, 2020
237fe5b
*: update tidb dependency build with go1.14 (#176)
3pointer Mar 10, 2020
0672ab3
*: add license header (#182)
overvenus Mar 11, 2020
9caa6de
conn: support not shutting down the storage when closing the connecti…
kennytm Mar 11, 2020
7d59284
conn: use GetDomain to avoid some TiDB breaking changes (#186)
overvenus Mar 11, 2020
0e25496
fix check safepoint & unhide experimental features (#175)
5kbpers Mar 11, 2020
3419d8a
support backupts (#172)
3pointer Mar 12, 2020
e476c82
*: update pd deps to v4 (#184)
kennytm Mar 12, 2020
9c2bf9d
restore: support online restore (#114)
disksing Mar 13, 2020
512855d
metrics: add grafana scripts (#140)
WangXiangUSTC Mar 15, 2020
6b88e51
filter out all TiFlash nodes when retrieving lists of stores from PD …
kennytm Mar 16, 2020
156f003
Create integration test for S3 storage (#174)
kennytm Mar 16, 2020
bbedfc8
Fix summary log (#191)
3pointer Mar 16, 2020
c3d26d9
Implement Raw Restore (#104)
MyonKeminta Mar 17, 2020
962c837
Merge branch 'master' into cherry-pick-3.1.0-rc
3pointer Mar 17, 2020
8236091
update dep
3pointer Mar 17, 2020
6268cde
restore: remove tiflash replica before restore (#194)
5kbpers Mar 18, 2020
4ea6c1c
summary: put summary log at last (#197)
3pointer Mar 19, 2020
2669204
*: abstract the progress channel (updateCh) into the glue package (#196)
kennytm Mar 20, 2020
a211bae
Merge branch 'master' into cherry-pick-3.1.0-rc
3pointer Mar 20, 2020
f9f6e19
*: refline logs (#189)
TennyZhuang Mar 20, 2020
9b96206
adapt pd/tidb related 3.1 changes
3pointer Mar 23, 2020
e168a60
tests: disable TLS test (#204)
overvenus Mar 24, 2020
4bc66c3
*: add S3 quick start and few enhancement of log (#202)
overvenus Mar 25, 2020
2f083c8
restore: add error field to `DownloadResponse` (#195)
5kbpers Mar 25, 2020
1f27b57
restore: populate restore cancel error (#207)
overvenus Mar 25, 2020
ae7688a
enhance usability of br (#208)
3pointer Mar 25, 2020
8638d9a
task: do not run checksum if restore failed (#209)
kennytm Mar 26, 2020
f112da7
fix incremental bug in llroad test (#199)
3pointer Mar 26, 2020
953ddf0
Merge branch 'master' into cherry-pick-3.1.0-rc
3pointer Mar 30, 2020
8fbedbf
add skip create sqls (#211)
3pointer Mar 30, 2020
f031777
Revert "tests: disable TLS test (#204)" (#218)
kennytm Mar 31, 2020
f7dc2db
doc: add `minio` to dependence list. (#221)
YuJuncen Apr 1, 2020
01de3f5
move waiting reject stores in import file (#222)
3pointer Apr 1, 2020
de4857c
Merge branch 'master' into cherry-pick-3.1.0-rc
3pointer Apr 2, 2020
3341f40
Max index length (#220)
3pointer Apr 2, 2020
7de169d
glue: create schema/table directly with info (#216)
kennytm Apr 2, 2020
ab69f59
Merge branch 'master' into cherry-pick-3.1.0-rc
3pointer Apr 2, 2020
14b4241
update deps
3pointer Apr 2, 2020
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
10 changes: 10 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
codecov:
require_ci_to_pass: yes

coverage:
status:
project:
default:
# Allow the coverage to drop by 3%
threshold: 3%
patch: off
1 change: 1 addition & 0 deletions .dockerignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ backupmeta
*.ngo
*.coverprofile
coverage.txt
docker/data/
docker/logs/
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {}
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@ Apache License
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.
limitations under the License.
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,28 @@ LDFLAGS += -X "$(BR_PKG)/pkg/utils.BRBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S
LDFLAGS += -X "$(BR_PKG)/pkg/utils.BRGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "$(BR_PKG)/pkg/utils.BRGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"

all: check test build
ifeq ("$(WITH_RACE)", "1")
RACEFLAG = -race
endif

release:
GO111MODULE=on go build -ldflags '$(LDFLAGS)' -o bin/br
all: check test build

build:
GO111MODULE=on go build -ldflags '$(LDFLAGS)' -race -o bin/br
GO111MODULE=on go build -ldflags '$(LDFLAGS)' ${RACEFLAG} -o bin/br

build_for_integration_test:
GO111MODULE=on go test -c -cover -covermode=count \
-coverpkg=$(BR_PKG)/... \
-o bin/br.test
# build key locker
GO111MODULE=on go build -race -o bin/locker tests/br_key_locked/*.go
GO111MODULE=on go build ${RACEFLAG} -o bin/locker tests/br_key_locked/*.go
# build gc
GO111MODULE=on go build -race -o bin/gc tests/br_z_gc_safepoint/*.go
GO111MODULE=on go build ${RACEFLAG} -o bin/gc tests/br_z_gc_safepoint/*.go
# build rawkv client
GO111MODULE=on go build ${RACEFLAG} -o bin/rawkv tests/br_rawkv/*.go

test:
GO111MODULE=on go test -race -tags leak ./...
GO111MODULE=on go test ${RACEFLAG} -tags leak ./...

testcover:
GO111MODULE=on retool do overalls \
Expand All @@ -46,6 +49,7 @@ integration_test: build build_for_integration_test
@which bin/pd-server
@which bin/pd-ctl
@which bin/go-ycsb
@which bin/minio
@which bin/br
tests/run.sh

Expand All @@ -71,6 +75,12 @@ static:
--disable interfacer \
--disable goimports \
--disable gofmt \
--disable wsl \
--disable funlen \
--disable whitespace \
--disable gocognit \
--disable godox \
--disable gomnd \
$$($(PACKAGE_DIRECTORIES))

lint:
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,41 @@ Notice BR supports building with Go version `Go >= 1.13`

When BR is built successfully, you can find binary in the `bin` directory.

## Quick start

```sh
# Start TiDB cluster
docker-compose -f docker-compose.yaml rm -s -v && \
docker-compose -f docker-compose.yaml build && \
docker-compose -f docker-compose.yaml up --remove-orphans

# Attach to control container to run BR
docker exec -it br_control_1 bash

# Load testing data to TiDB
go-ycsb load mysql -p workload=core \
-p mysql.host=tidb -p mysql.port=4000 -p mysql.user=root \
-p recordcount=100000 -p threadcount=100

# How many rows do we get? 100000 rows.
mysql -uroot -htidb -P4000 -E -e "SELECT COUNT(*) FROM test.usertable"

# Build BR and backup!
make release && \
bin/br backup full --pd pd0:2379 --storage "local:///data/backup/full" \
--log-file "/logs/br_backup.log"

# Let's drop database.
mysql -uroot -htidb -P4000 -E -e "DROP DATABASE test; SHOW DATABASES;"

# Restore!
bin/br restore full --pd pd0:2379 --storage "local:///data/backup/full" \
--log-file "/logs/br_restore.log"

# How many rows do we get again? Expected to be 100000 rows.
mysql -uroot -htidb -P4000 -E -e "SELECT COUNT(*) FROM test.usertable"
```

## Contributing

Contributions are welcomed and greatly appreciated. See [CONTRIBUTING](./CONTRIBUTING.md)
Expand Down
34 changes: 31 additions & 3 deletions cmd/backup.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package cmd

import (
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/session"
"github.com/spf13/cobra"

"github.com/pingcap/br/pkg/gluetikv"
"github.com/pingcap/br/pkg/summary"
"github.com/pingcap/br/pkg/task"
"github.com/pingcap/br/pkg/utils"
Expand All @@ -15,14 +18,23 @@ func runBackupCommand(command *cobra.Command, cmdName string) error {
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
return err
}
return task.RunBackup(GetDefaultContext(), cmdName, &cfg)
return task.RunBackup(GetDefaultContext(), tidbGlue, cmdName, &cfg)
}

func runBackupRawCommand(command *cobra.Command, cmdName string) error {
cfg := task.RawKvConfig{Config: task.Config{LogProgress: HasLogFile()}}
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
return err
}
return task.RunBackupRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg)
}

// NewBackupCommand return a full backup subcommand.
func NewBackupCommand() *cobra.Command {
command := &cobra.Command{
Use: "backup",
Short: "backup a TiDB cluster",
Use: "backup",
Short: "backup a TiDB/TiKV cluster",
SilenceUsage: false,
PersistentPreRunE: func(c *cobra.Command, args []string) error {
if err := Init(c); err != nil {
return err
Expand All @@ -43,6 +55,7 @@ func NewBackupCommand() *cobra.Command {
newFullBackupCommand(),
newDbBackupCommand(),
newTableBackupCommand(),
newRawBackupCommand(),
)

task.DefineBackupFlags(command.PersistentFlags())
Expand Down Expand Up @@ -87,3 +100,18 @@ func newTableBackupCommand() *cobra.Command {
task.DefineTableFlags(command)
return command
}

// newRawBackupCommand return a raw kv range backup subcommand.
func newRawBackupCommand() *cobra.Command {
// TODO: remove experimental tag if it's stable
command := &cobra.Command{
Use: "raw",
Short: "(experimental) backup a raw kv range from TiKV cluster",
RunE: func(command *cobra.Command, _ []string) error {
return runBackupRawCommand(command, "Raw backup")
},
}

task.DefineRawBackupFlags(command)
return command
}
20 changes: 14 additions & 6 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package cmd

import (
Expand All @@ -13,6 +15,7 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/pingcap/br/pkg/gluetidb"
"github.com/pingcap/br/pkg/task"
"github.com/pingcap/br/pkg/utils"
)
Expand All @@ -21,6 +24,7 @@ var (
initOnce = sync.Once{}
defaultContext context.Context
hasLogFile uint64
tidbGlue = gluetidb.Glue{}
)

const (
Expand Down Expand Up @@ -84,16 +88,20 @@ func Init(cmd *cobra.Command) (err error) {
err = e
return
}
tidbLogCfg := logutil.LogConfig{}
if len(slowLogFilename) != 0 {
slowCfg := logutil.LogConfig{SlowQueryFile: slowLogFilename}
e = logutil.InitLogger(&slowCfg)
if e != nil {
err = e
return
}
tidbLogCfg.SlowQueryFile = slowLogFilename
} else {
// Hack! Discard slow log by setting log level to PanicLevel
logutil.SlowQueryLogger.SetLevel(logrus.PanicLevel)
// Disable annoying TiDB Log.
// TODO: some error logs outputs randomly, we need to fix them in TiDB.
tidbLogCfg.Level = "fatal"
}
e = logutil.InitLogger(&tidbLogCfg)
if e != nil {
err = e
return
}

// Initialize the pprof server.
Expand Down
55 changes: 52 additions & 3 deletions cmd/restore.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package cmd

import (
"github.com/pingcap/tidb/session"
"github.com/spf13/cobra"

"github.com/pingcap/br/pkg/gluetikv"
"github.com/pingcap/br/pkg/summary"
"github.com/pingcap/br/pkg/task"
"github.com/pingcap/br/pkg/utils"
Expand All @@ -14,14 +17,34 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error {
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
return err
}
return task.RunRestore(GetDefaultContext(), cmdName, &cfg)
return task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg)
}

func runRestoreRawCommand(command *cobra.Command, cmdName string) error {
cfg := task.RestoreRawConfig{
RawKvConfig: task.RawKvConfig{Config: task.Config{LogProgress: HasLogFile()}},
}
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
return err
}
return task.RunRestoreRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg)
}

func runRestoreTiflashReplicaCommand(command *cobra.Command, cmdName string) error {
cfg := task.RestoreConfig{Config: task.Config{LogProgress: HasLogFile()}}
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
return err
}

return task.RunRestoreTiflashReplica(GetDefaultContext(), tidbGlue, cmdName, &cfg)
}

// NewRestoreCommand returns a restore subcommand
func NewRestoreCommand() *cobra.Command {
command := &cobra.Command{
Use: "restore",
Short: "restore a TiKV cluster from a backup",
Use: "restore",
Short: "restore a TiDB/TiKV cluster",
SilenceUsage: false,
PersistentPreRunE: func(c *cobra.Command, args []string) error {
if err := Init(c); err != nil {
return err
Expand All @@ -40,6 +63,8 @@ func NewRestoreCommand() *cobra.Command {
newFullRestoreCommand(),
newDbRestoreCommand(),
newTableRestoreCommand(),
newRawRestoreCommand(),
newTiflashReplicaRestoreCommand(),
)
task.DefineRestoreFlags(command.PersistentFlags())

Expand Down Expand Up @@ -80,3 +105,27 @@ func newTableRestoreCommand() *cobra.Command {
task.DefineTableFlags(command)
return command
}

func newTiflashReplicaRestoreCommand() *cobra.Command {
command := &cobra.Command{
Use: "tiflash-replica",
Short: "restore the tiflash replica before the last restore, it must only be used after the last restore failed",
RunE: func(cmd *cobra.Command, _ []string) error {
return runRestoreTiflashReplicaCommand(cmd, "Restore TiFlash Replica")
},
}
return command
}

func newRawRestoreCommand() *cobra.Command {
command := &cobra.Command{
Use: "raw",
Short: "(experimental) restore a raw kv range to TiKV cluster",
RunE: func(cmd *cobra.Command, _ []string) error {
return runRestoreRawCommand(cmd, "Raw restore")
},
}

task.DefineRawRestoreFlags(command)
return command
}
Loading