Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: merging tidb-lightning to release-4.0 #746

Merged
merged 365 commits into from
Mar 3, 2021

Conversation

overvenus
Copy link
Member

What problem does this PR solve?

This PR merges TiDB-Lightning into release-4.0 branch, a cherry-pick of #665.

To facilitate review, it targets subtree-lightning-release-4.0 temporary, will targets to and squash merges into release-4.0 after LGTM2.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

  • Increased code complexity

Release Note

  • No release note.

lonng and others added 30 commits March 8, 2019 18:08
…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
The character is too exotic and breaks TiDB and some old git.
…ss (pingcap#178)

If no files are completely imported within the first 5 minutes, we get
`finished == 0` and the logger will try to log a nil field and crashes.
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>
@glorv
Copy link
Collaborator

glorv commented Mar 1, 2021

/lgtm

@ti-srebot ti-srebot added the status/LGT1 LGTM1 label Mar 1, 2021
@kennytm
Copy link
Collaborator

kennytm commented Mar 2, 2021

/lgtm

@ti-srebot ti-srebot removed the status/LGT1 LGTM1 label Mar 2, 2021
ti-srebot
ti-srebot previously approved these changes Mar 2, 2021
@ti-srebot ti-srebot added the status/LGT2 LGTM2 label Mar 2, 2021
@overvenus overvenus changed the base branch from subtree-lightning-release-4.0 to release-4.0 March 3, 2021 05:41
@overvenus overvenus dismissed ti-srebot’s stale review March 3, 2021 05:41

The base branch was changed.

@CLAassistant
Copy link

CLAassistant commented Mar 3, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
8 out of 10 committers have signed the CLA.

✅ kennytm
✅ lichunzhu
✅ 3pointer
✅ Little-Wallace
✅ glorv
✅ zjj2wry
✅ overvenus
✅ lance6716
❌ xuhui-lu
❌ hidehalo
You have signed the CLA already but the status is still pending? Let us recheck it.

@3pointer
Copy link
Collaborator

3pointer commented Mar 3, 2021

/lgtm

@ti-srebot ti-srebot removed the status/LGT2 LGTM2 label Mar 3, 2021
@ti-srebot ti-srebot added the status/LGT3 LGTM3. This PR looks very good to our bot. label Mar 3, 2021
@overvenus overvenus merged commit 348eb2b into pingcap:release-4.0 Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/import status/LGT3 LGTM3. This PR looks very good to our bot. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet