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

*: merging tidb-lightning #665

Merged
merged 362 commits into from
Feb 19, 2021
Merged

*: merging tidb-lightning #665

merged 362 commits into from
Feb 19, 2021

Conversation

overvenus
Copy link
Member

@overvenus overvenus commented Dec 29, 2020

What problem does this PR solve?

Merging TiDB-Lightning repo into BR repo.

What is changed and how it works?

git subtree add -P pkg/lightning https://github.com/pingcap/br/pkg/lightning.git in subtree-lightning branch.

This PR targets to subtree-lightning branch for easier review, also it includes changes on import path and lightning tests (to pass BR CI).

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

Release Note

  • No release note

zhouqiang-cl and others added 30 commits January 26, 2019 23:19
…rt` (pingcap#119)

* restore: resolve conflicts

* restore: do not do compact after engine file imported

* restore: address comment

* worker: panic if recycle a nil worker

* restore: resolve conflicts

* restore: init

* *: address comment

* *: address comment

* config: change default value of `level-1-compact`

Co-Authored-By: lonng <chris@lonng.org>
…ingcap#132)

* restore: write index kvs and data kvs to seperate engine

* restore: rename  to

* restore: use single engine file to store index

* restore: make index engine limited by table concurrency

* restore: revert some changes

* restore: modify checkpoint proto

* restore: implement checkpoint for index engine file

* tests: add failpoint for CheckpointStatusIndexImported

* address comment

* address comment

* address comment
* loader: recognize CSV files

* *: generalize the parser interface

* mydump: added a CSV parser

* mydump,restore: enable CSV parser

* tests: added integration test for CSV

* mydumper: added test case for empty CSV

* config: improved description

* restore: fixed a compile error on Go 1.12
update tidb version to latest release2.1, and add a test case for issue pingcap/tidb#9532
…ingcap#142)

Currently, cleanup script in integration test does not work, if the developer wants to re-run integration test in his/her local environment, he/she has to clean /tmp/lightning_test_result manually
Test `checkpoint_error_destroy` in integration got error randomly, both in local environment and JenkinsCI.
Lightning could exit before all checkpoints are saved, as the `WaitGroup` is not always 
added before this line https://github.com/pingcap/tidb-lightning/blob/master/lightning/restore/restore.go#L204 returns

1. After `RestoreController.Run` is returned, no more messages will be sent to `rc.saveCpCh`, so we can close it safely and ensure all `saveCp` are consumed
2. remove some unused code
* restore: add local checksum log

* Update lightning/restore/restore.go

Co-Authored-By: lonng <chris@lonng.org>
use gofail to control lightning to kill itself after one chunk is imported
…ingcap#145)

* *: parse the data source directly into data and skip the KV encoder

This skips the more complex pingcap/parser, and speeds up parsing speed
by 50%.

We have also refactored the KV delivery mechanism to use channels
directly, and revamped metrics:

- Make the metrics about engines into its own `engines` counter. The
  `tables` counter is exclusively about tables now.
- Removed `block_read_seconds`, `block_read_bytes`, `block_encode_seconds`
  since the concept of "block" no longer applies. Replaced by the
  equivalents named `row_***`.
- Removed `chunk_parser_read_row_seconds` for being overlapping with
  `row_read_seconds`.
- Changed `block_deliver_bytes` into a histogram vec, with kind=index
  or kind=data. Introduced `block_deliver_kv_pairs`.

* tests,restore: prevent spurious error in checkpoint_chunks test

Only kill Lightning if the whole chunk is imported exactly. The chunk
checkpoint may be recorded before a chunk is fully written, and this will
hit the failpoint more than 5 times.

* kv: use composed interface to simplify some types

* kv: properly handle the SQL mode

* common: disable IsContextCanceledError() when log level = debug

This helps debugging some mysterious cancellation where the log is
inhibited.

Added IsReallyContextCanceledError() for code logic affected by error
type.

* restore: made some log more detailed

* restore: made the SlowDownImport failpoint apply to index engines too

* restore: do not open a write stream when there are no KV pairs to send

* tests: ensure we drop the checkpoints DB before re-run

* mydump: fixed various off-by-one errors in the CSV parser

* *: rename `!IsContextCanceledError` to `ShouldLogError`

* *: addressed comments

* restore: zero the checksums and column permutations on initialization

* *: addressed comments

* tests: add back a missing license header

* tests: improve a comment.
…gcap#158 (pingcap#159)

* tests: fix a test failure due to conflict between pingcap#145 and pingcap#158

* restore: apply the row count limit to failpoint KillIfImportedChunk too
Put the large table in the front of the slice which can avoid large table take a long time to import and block small table to release index worker.
* config: remove deprecated -compact, -switch-mode flags from tidb-lightning

They can still be called from tidb-lightning-ctl.

* config: search also conf/tidb-lightning.toml for default -config path

Fallback to standard default if -config is not supplied

* config: provide command line arguments for some common options

* config: stop searching for tidb-lightning.toml if --config is unspecified
* tests: fix existing test failure

* mydump: fixed conversion of integers into bits

We need to create a special branch for integers, since casting 123 and
'123' into BIT type behave differently.

Also fixed handling of 0x/0b bit strings since Ragel doesn't recognize
'+' in a regex -_-.

* mydump: store description of `token` in an array instead of switch cases

* tests: test behavior of integers for ENUM and SET types as well
* *: use pingcap/log (zap) for logging

Some redundant logs (e.g. logging about the same thing inside and outside
a function) are removed.

The {QueryRow,Transact,Exec}WithRetry functions are revamped to include
the logger.

* common,config: addressed comments

* *: addressed comments

* restore,verification: addressed comments
* kv: fix handling of column default values

* if the column is AUTO_INCREMENT, fill in with row_id (assume it is
  missing for the entire table instead of just a few values)
* if the column has DEFAULT, fill in that value

* tests: ensure DEFAULT CURRENT_TIMESTAMP works
Ensures table + index <= the default max-open-engine which is 8.
* config: added [[routes]] config

* mydump, restore: support table routing

* tests: added test case for table routing

* mydump: ensure rerouted schemas will not be created

* config: allows routes to be case-sensitive

* restore: replace CREATE TABLE -> IF NOT EXISTS using tidb/parser

* mydump/loader_test: add unit test for route() and refactor

* tests: TiDB doesn't support `DECIMAL(20, 0)`.

* tests: workaround pingcap/parser#310
@overvenus
Copy link
Member Author

WIP to block bot merge (will merge manually).

…a56b7'

git-subtree-dir: pkg/lightning
git-subtree-mainline: cb828b8
git-subtree-split: 1f12021
Also it makes changes:

* format lightning code using gofumports
* move lightning/cmd to cmd
* merge files, including
  * go.mod1, go.sum1
  * .gitignore
  * .github/*
  * Makefile
  * tools/*

Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus changed the base branch from subtree-lightning to master February 19, 2021 05:45
@ti-srebot ti-srebot added status/LGT3 LGTM3. This PR looks very good to our bot. and removed status/LGT2 LGTM2 labels Feb 19, 2021
@overvenus overvenus merged commit 8b9b626 into pingcap:master Feb 19, 2021
ti-srebot pushed a commit to ti-srebot/br that referenced this pull request Feb 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0-rc in PR #740

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.