Skip to content

Commit

Permalink
Release 4.0 merge master (pingcap#200)
Browse files Browse the repository at this point in the history
* restore: merge tidb-tools/pkg/restore-util (pingcap#146)

* restore-util: Implement split/scatter (pingcap#274)

* implement split/scatter

Signed-off-by: 5kbpers <[email protected]>

* init test

Signed-off-by: 5kbpers <[email protected]>

* redesign output/input of the lib

Signed-off-by: 5kbpers <[email protected]>

* update dependency

Signed-off-by: 5kbpers <[email protected]>

* add commments and more tests

Signed-off-by: 5kbpers <[email protected]>

* add ScanRegions interface to Client

Signed-off-by: 5kbpers <[email protected]>

* fix potential data race

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* Apply suggestions from code review

Co-Authored-By: kennytm <[email protected]>

* Update pkg/restore-util/client.go

Co-Authored-By: kennytm <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* update dependency

Signed-off-by: 5kbpers <[email protected]>

* resolve conflicts

Signed-off-by: 5kbpers <[email protected]>

* fix prefix rewrite

Signed-off-by: 5kbpers <[email protected]>

* add RewriteRule/skip failed scatter region/retry the SplitRegion

Signed-off-by: 5kbpers <[email protected]>

* fix test

Signed-off-by: 5kbpers <[email protected]>

* check if region has peer

Signed-off-by: 5kbpers <[email protected]>

* more logs

Signed-off-by: 5kbpers <[email protected]>

* restore-util: add split retry interval (pingcap#277)

* reset dependencies to release-3.1

* add split retry interval

Signed-off-by: 5kbpers <[email protected]>

* fix go.sum

Signed-off-by: 5kbpers <[email protected]>

* restore-util: wait for scatter region sequentially  (pingcap#279)

* wait for scatter region sequentially

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* restore-util: add on split hook (pingcap#281)

* restore-util: add on split hook

Signed-off-by: Neil Shen <[email protected]>

* Nil check onSplit

Co-Authored-By: kennytm <[email protected]>

* restore-util: fix returned new region is nil (pingcap#283)

* restore-util: fix returned new region is nil

Signed-off-by: 5kbpers <[email protected]>

* more logs

Signed-off-by: 5kbpers <[email protected]>

* *: gofmt

Signed-off-by: 5kbpers <[email protected]>

* Apply suggestions from code review

Co-Authored-By: kennytm <[email protected]>

* fix log

Signed-off-by: 5kbpers <[email protected]>

* restore-util: call onSplit on splitByRewriteRules (pingcap#285)

Signed-off-by: Neil Shen <[email protected]>

* restore-util: fix overlapped error message (pingcap#293)

* restore-util: fix overlapped error message

Signed-off-by: 5kbpers <[email protected]>

* fix log message

Signed-off-by: 5kbpers <[email protected]>

* reduce error trace

Signed-off-by: 5kbpers <[email protected]>

* fix test

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* restore-util: log warning when cannot find matched rewrite rule (pingcap#299)

* restore-util: add method to set placement rules and store labels (pingcap#301)

* restore-util: add method to set placement rules and store labels

Signed-off-by: disksing <[email protected]>

* minor fix

Signed-off-by: disksing <[email protected]>

* address comment

Signed-off-by: disksing <[email protected]>

* add GetPlacementRules

Signed-off-by: disksing <[email protected]>

* fix test

Signed-off-by: disksing <[email protected]>

* restore-util: support batch split (pingcap#300)

* restore-util: support batch split

Signed-off-by: 5kbpers <[email protected]>

* go fmt

Signed-off-by: 5kbpers <[email protected]>

* Apply suggestions from code review

Co-Authored-By: kennytm <[email protected]>

* address commits

Signed-off-by: 5kbpers <[email protected]>

* Update pkg/restore-util/split.go

Co-Authored-By: kennytm <[email protected]>

* add onSplit callback

Signed-off-by: 5kbpers <[email protected]>

* fix test

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* restore-util: add upper bound time for waiting for scatter (pingcap#305)

* restore: fix scatter regions failed

Signed-off-by: 5kbpers <[email protected]>

* add log

Signed-off-by: 5kbpers <[email protected]>

* stop waiting for scatter after 3min

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* restore-util: fix wrong url (pingcap#306)

Signed-off-by: disksing <[email protected]>

* restore-util: add warning about unmatched table id (pingcap#313)

* restore-util: support table partition

Signed-off-by: 5kbpers <[email protected]>

* fix log

Signed-off-by: 5kbpers <[email protected]>

* warn table id does not match

Signed-off-by: 5kbpers <[email protected]>

* add unit tests

Signed-off-by: 5kbpers <[email protected]>

* Apply suggestions from code review

Co-Authored-By: Neil Shen <[email protected]>

* fix compile error

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* fix test

Signed-off-by: 5kbpers <[email protected]>

Co-authored-by: Ian <[email protected]>
Co-authored-by: Neil Shen <[email protected]>

* *: prune tidb-tools

Signed-off-by: Neil Shen <[email protected]>

* restore: address linters suggestions

Signed-off-by: Neil Shen <[email protected]>

* restore: merge restoreutil into restore

Signed-off-by: Neil Shen <[email protected]>

* address comment

Signed-off-by: Neil Shen <[email protected]>

Co-authored-by: 5kbpers <[email protected]>
Co-authored-by: kennytm <[email protected]>
Co-authored-by: disksing <[email protected]>
Co-authored-by: Ian <[email protected]>

* Fixed handling for a dbName that do not exist in the backup being restored (pingcap#148)

* Fixed handling for a dbName that do not exist in the backup being restored

* Fixed handling for a dbName that do not exist in the backup being restored

* validate: fix debug meta test ci (pingcap#153)

* validate: fix debug meta test ci

* *: extracts runBackup/runRestore in cmd into pkg/task (pingcap#156)

* *: extracts runBackup/runRestore in cmd into pkg/task

Defines a "Config" structure to store the parsed flags.

Use the "black-white-list" structure to define what tables/databases to
backup/restore.

* go.mod: update tidb to v4.0.0-beta

* restore: fix restore summary log (pingcap#150)

Co-authored-by: kennytm <[email protected]>

* restore: enhance error handling (pingcap#152)

* restore: enhance error handling

Signed-off-by: 5kbpers <[email protected]>

* unit test

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* fix region epoch error

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* remove `Restore*`

Signed-off-by: 5kbpers <[email protected]>

* address lint

Signed-off-by: 5kbpers <[email protected]>

* add debug log

Signed-off-by: 5kbpers <[email protected]>

* Apply suggestions from code review

Co-Authored-By: kennytm <[email protected]>

* Update pkg/restore/import.go

Co-Authored-By: kennytm <[email protected]>

* fix retry error

Signed-off-by: 5kbpers <[email protected]>

* handle RegionNotFound error

Signed-off-by: 5kbpers <[email protected]>

Co-authored-by: Neil Shen <[email protected]>
Co-authored-by: kennytm <[email protected]>

* Incremental BR: support DDL (pingcap#155)

* support backup&restore ddl

Signed-off-by: 5kbpers <[email protected]>

* integration tests

Signed-off-by: 5kbpers <[email protected]>

* update kvproto

Signed-off-by: 5kbpers <[email protected]>

* fix integration tests

Signed-off-by: 5kbpers <[email protected]>

* reduce cyclomatic complexity of `runRestore`

Signed-off-by: 5kbpers <[email protected]>

* fix test

Signed-off-by: 5kbpers <[email protected]>

* add unit test

Signed-off-by: 5kbpers <[email protected]>

* fix tests

Signed-off-by: 5kbpers <[email protected]>

* disable fast checksum in incremental br

Signed-off-by: 5kbpers <[email protected]>

* fix no valid key error

Signed-off-by: 5kbpers <[email protected]>

* address lint

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* Reduce TiDB dependencies (pingcap#158)

* utils: exclude mock_cluster outside of unit test

* utils: remove unused ResultSetToStringSlice()

* *: abstract away dependencies of tidb/session into a Glue interface

* *: fix hound lint

* util,mock: move utils.MockCluster to mock.Cluster

* restore: fix test build failure

Co-authored-by: 3pointer <[email protected]>

* go.mod: update tidb (pingcap#168)

Signed-off-by: Neil Shen <[email protected]>

* BR support TLS (pingcap#161)

* *: support tls

* move tikv.driver to glue

* fix comments

* upgrade golangci and prepare for go 1.14 (pingcap#171)

Signed-off-by: Neil Shen <[email protected]>

* backup: add raw backup command (pingcap#101)

* backup: add raw backup command

* restore: speed up retry on not leader (pingcap#179)

* tests: stable cluster start up

Signed-off-by: Neil Shen <[email protected]>

* tests: fix unbound var

Signed-off-by: Neil Shen <[email protected]>

* restore: speed retry on not leader

Signed-off-by: Neil Shen <[email protected]>

* address comments

Signed-off-by: Neil Shen <[email protected]>

* tests: add --cacert flag

Signed-off-by: Neil Shen <[email protected]>

* make codecov green

Signed-off-by: Neil Shen <[email protected]>

* address comments

Signed-off-by: Neil Shen <[email protected]>

* conn, restore: paginate scan regions (pingcap#165)

* conn, restore: paginate scan regions

Signed-off-by: Neil Shen <[email protected]>

* tests: large timeout

Signed-off-by: Neil Shen <[email protected]>

* Batch restore (pingcap#167)

* *: unify Range and RangeTree

Signed-off-by: Neil Shen <[email protected]>

* restore: split restore files into small batch

Signed-off-by: Neil Shen <[email protected]>

* task: set default restore concurrency to 128

Signed-off-by: Neil Shen <[email protected]>

* restore: unused table worker pool

Signed-off-by: Neil Shen <[email protected]>

* summary: sum up repeated duration and int

Signed-off-by: Neil Shen <[email protected]>

* rtree: move rtree from utils to pkg

Signed-off-by: Neil Shen <[email protected]>

* README, docker: add quick start (pingcap#181)

* README, docker: add quick start

Signed-off-by: Neil Shen <[email protected]>

* cmd: disable some TiDB log

Signed-off-by: Neil Shen <[email protected]>

* docker: build go-ycsb automatically

Signed-off-by: Neil Shen <[email protected]>

* cmd: add TODO about TiDB logs

Signed-off-by: Neil Shen <[email protected]>

* *: update tidb dependency build with go1.14 (pingcap#176)

* *: add license header (pingcap#182)

* rtree: move checkFile into backup

Signed-off-by: Neil Shen <[email protected]>

* *: add license header

Signed-off-by: Neil Shen <[email protected]>

* Update LICENSE.md

Co-Authored-By: kennytm <[email protected]>

Co-authored-by: kennytm <[email protected]>
Co-authored-by: 3pointer <[email protected]>

* conn: support not shutting down the storage when closing the connection (pingcap#185)

Co-authored-by: 3pointer <[email protected]>

* conn: use GetDomain to avoid some TiDB breaking changes (pingcap#186)

* conn: use GetDomain to avoid some TiDB breaking changes

Signed-off-by: Neil Shen <[email protected]>

* minor usability improvement

Signed-off-by: Neil Shen <[email protected]>

Co-authored-by: kennytm <[email protected]>

* fix check safepoint & unhide experimental features (pingcap#175)

* backup: check safepoint for last backup ts

Signed-off-by: 5kbpers <[email protected]>

* check lastbackupts > 0

Signed-off-by: 5kbpers <[email protected]>

* unhide experimental features

Signed-off-by: 5kbpers <[email protected]>

* address comment

Signed-off-by: 5kbpers <[email protected]>

* Update tests/br_z_gc_safepoint/run.sh

Co-Authored-By: kennytm <[email protected]>

Co-authored-by: kennytm <[email protected]>

* support backupts (pingcap#172)

* support backupts

* address comment

* address comment

* fix space

* *: update pd deps to v4 (pingcap#184)

Co-authored-by: 3pointer <[email protected]>

* restore: support online restore (pingcap#114)

Signed-off-by: disksing <[email protected]>

* metrics: add grafana scripts (pingcap#140)

* add grafana scripts

* fix

Co-authored-by: 3pointer <[email protected]>
Co-authored-by: glorv <[email protected]>
Co-authored-by: kennytm <[email protected]>

* filter out all TiFlash nodes when retrieving lists of stores from PD (pingcap#187)

* conn: ignore nodes with label engine=tiflash

* conn: disallow TiFlash on restore, only skip TiFlash on backup

* Create integration test for S3 storage (pingcap#174)

* Fix summary log (pingcap#191)

* *: fix restore summary log after restore logic changed to files

* fix

* fix

* fix

Co-authored-by: kennytm <[email protected]>

* Implement Raw Restore (pingcap#104)

* Update kvproto

* Implement raw restore

* fix build

* Set range for file importer

Signed-off-by: MyonKeminta <[email protected]>

* Remove unnecessary comments

Signed-off-by: MyonKeminta <[email protected]>

* check cf and support multi ranges in BackupMeta

Signed-off-by: MyonKeminta <[email protected]>

* Check files' cf; address comments

* adjust structure to keep consistent with master

* Fix build

Signed-off-by: MyonKeminta <[email protected]>

* Fix build and make check, avoid accessing TiDB in rawkv mode

* Fix test

Signed-off-by: MyonKeminta <[email protected]>

* Fix tests

Signed-off-by: MyonKeminta <[email protected]>

* Fix broken logic after merging master

* Update pkg/task/restore_raw.go

Co-Authored-By: Neil Shen <[email protected]>

* Address comments

* Address comments

* Mark raw restore as experimental

* Fix build

* Address comments

* test: Add check for deleting data and partial backup

* Fix build

* Add license header

* fix ci

* fix ci

Co-authored-by: MyonKeminta <[email protected]>
Co-authored-by: 3pointer <[email protected]>
Co-authored-by: Neil Shen <[email protected]>
Co-authored-by: pingcap-github-bot <[email protected]>

* restore: remove tiflash replica before restore (pingcap#194)

* restore: remove tiflash replica before restore

Signed-off-by: 5kbpers <[email protected]>

* rename errSplit variable

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* check replica count by region info

Signed-off-by: 5kbpers <[email protected]>

* cleanup

Signed-off-by: 5kbpers <[email protected]>

* save tiflash replica count to backupmeta

Signed-off-by: 5kbpers <[email protected]>

* fix save crcxor

Signed-off-by: 5kbpers <[email protected]>

* fix decode the key of placement rule

Signed-off-by: 5kbpers <[email protected]>

* address lint

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* close domain after restoring tiflash-replica

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* address comments

Signed-off-by: 5kbpers <[email protected]>

* Update pkg/task/restore.go

Co-Authored-By: 3pointer <[email protected]>

Co-authored-by: 3pointer <[email protected]>

* summary: put summary log at last (pingcap#197)

* summary: put summary log at last

* fix switch sql

Co-authored-by: Neil Shen <[email protected]>
Co-authored-by: 5kbpers <[email protected]>
Co-authored-by: kennytm <[email protected]>
Co-authored-by: disksing <[email protected]>
Co-authored-by: Ian <[email protected]>
Co-authored-by: Kolbe Kegel <[email protected]>
Co-authored-by: WangXiangUSTC <[email protected]>
Co-authored-by: glorv <[email protected]>
Co-authored-by: MyonKeminta <[email protected]>
Co-authored-by: MyonKeminta <[email protected]>
Co-authored-by: pingcap-github-bot <[email protected]>
  • Loading branch information
12 people authored Mar 20, 2020
1 parent 0c1dea4 commit 3239e7d
Show file tree
Hide file tree
Showing 122 changed files with 8,985 additions and 1,861 deletions.
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/
7 changes: 4 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ issues:
text: "Potential HTTP request made with variable url"
linters:
- gosec
- path: .go
text: "Use of weak random number generator"
# TODO Remove it.
- path: split_client.go
text: "SA1019:"
linters:
- gosec
- staticcheck
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
Loading

0 comments on commit 3239e7d

Please sign in to comment.