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

Lightning: add a pre check before import starts. #999

Merged
merged 8 commits into from
Jun 10, 2021

Conversation

3pointer
Copy link
Collaborator

@3pointer 3pointer commented Apr 13, 2021

What problem does this PR solve?

Add some checks before lightning start imports.

close #1107

What is changed and how it works?

  1. Replace checkRequirements with PreCheck.
  2. Add DataCheck after restoreSchemas
  3. All checks add in check_info.go
  4. Use go-pretty to render output template.
  5. Depreacated skip-chech-path

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Note

  • Add pre-check before lightning starts.

@3pointer
Copy link
Collaborator Author

/rebuild

pkg/lightning/common/util.go Outdated Show resolved Hide resolved
CaseSensitive bool `toml:"case-sensitive" json:"case-sensitive"`
StrictFormat bool `toml:"strict-format" json:"strict-format"`
DefaultFileRules bool `toml:"default-file-rules" json:"default-file-rules"`
IgnoreColumns map[string][]string `toml:"ignore-columns" json:"ignore-columns"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use []IgnoreColumns here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we need specify db.table for this config.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rethinked about this , I think it's better to use the same rule as table filter to support regexp

pkg/lightning/config/config.go Outdated Show resolved Hide resolved
pkg/lightning/config/config.go Outdated Show resolved Hide resolved
pkg/storage/s3.go Show resolved Hide resolved
@3pointer 3pointer force-pushed the lightning_pre_check branch 2 times, most recently from e634937 to 7a7abad Compare April 27, 2021 06:55
@3pointer
Copy link
Collaborator Author

3pointer commented May 7, 2021

/run-integration-tests

@3pointer 3pointer force-pushed the lightning_pre_check branch from 1983aa9 to a4cf617 Compare May 12, 2021 12:28
@3pointer
Copy link
Collaborator Author

/run-integration-tests

@3pointer
Copy link
Collaborator Author

/run-all-tests

@CLAassistant
Copy link

CLAassistant commented May 25, 2021

CLA assistant check
All committers have signed the CLA.

@3pointer 3pointer marked this pull request as ready for review May 25, 2021 09:37
@glorv glorv added this to the v5.1.0 milestone Jun 2, 2021
pkg/lightning/config/config.go Show resolved Hide resolved
pkg/lightning/mydump/loader.go Show resolved Hide resolved
pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/restore.go Show resolved Hide resolved
pkg/lightning/restore/restore_test.go Outdated Show resolved Hide resolved
pkg/task/common.go Outdated Show resolved Hide resolved
pkg/lightning/restore/restore_test.go Show resolved Hide resolved
pkg/lightning/config/config.go Outdated Show resolved Hide resolved
@glorv
Copy link
Collaborator

glorv commented Jun 2, 2021

@3pointer Please rebase your pr to make the cla check happy

@3pointer 3pointer force-pushed the lightning_pre_check branch from 7b2dcc0 to 8ccce25 Compare June 3, 2021 12:38
@kennytm
Copy link
Collaborator

kennytm commented Jun 4, 2021

@3pointer the commit 85440dd's author is still root <root>.

func AskForConfirmation() bool {
var response string
fmt.Println("please type [y/N] to continue:")
_, err := fmt.Scanln(&response)
Copy link
Collaborator

@kennytm kennytm Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have i missed something? i've never seen any design doc saying that supporting pre-check will turn Lightning into an interactive-CLI tool

looking at the changes to the test cases show that introducing interactivity will break a lot of Lightning use cases. also given the history of dmctl I seriously doubt introducing interactivity is a good idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add the interactivity because I found lightning will start to import automatically even we had some warning in pre-check.
so the user had to kill lightning and start it again, and if the user(it was me) didn't fix the waring in one time. he must kill lightning and start again and again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could make the checks fatal, and having --disable-checks=aaa,bbb,ccc (or the opposite --enable-checks=xxx,yyy,zzz) to toggle the checks. the error message to mention the corresponding CLI paramters and config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made the checks fatal and reuse --check-requirements to disable the checks.
Because it's not necessary to skip some checks.

@3pointer 3pointer force-pushed the lightning_pre_check branch 3 times, most recently from 9700be9 to 75d3607 Compare June 4, 2021 11:40
@3pointer 3pointer force-pushed the lightning_pre_check branch 2 times, most recently from 9700be9 to 6b3a8c2 Compare June 4, 2021 12:09
CaseSensitive bool `toml:"case-sensitive" json:"case-sensitive"`
StrictFormat bool `toml:"strict-format" json:"strict-format"`
DefaultFileRules bool `toml:"default-file-rules" json:"default-file-rules"`
IgnoreColumns map[string][]string `toml:"ignore-columns" json:"ignore-columns"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rethinked about this , I think it's better to use the same rule as table filter to support regexp

pdStores = "/pd/api/v1/stores"
pdReplicate = "/pd/api/v1/config/replicate"

defaultCSVSize = 10 * units.GiB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does 1GiB already enough? I think 10GB is too large

pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/restore_test.go Outdated Show resolved Hide resolved
pkg/lightning/restore/restore.go Show resolved Hide resolved
pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/check_info.go Show resolved Hide resolved
pkg/lightning/restore/check_info.go Show resolved Hide resolved
pkg/lightning/restore/check_info.go Outdated Show resolved Hide resolved
pkg/lightning/restore/check_info.go Show resolved Hide resolved
return errors.New("no schema create sql files found. Please either set `mydumper.no-schema` to true or add schema sql file for each database")
}
// setup database schema
if len(s.dbSchemas) != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(s.dbSchemas) != 0 {
if len(s.dbSchemas) != 0 || len(s.tableSchemas) != 0 {

Copy link
Collaborator

@glorv glorv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 LGTM1 label Jun 9, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • glorv
  • kennytm

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 LGTM2 and removed status/LGT1 LGTM1 labels Jun 9, 2021
@3pointer
Copy link
Collaborator Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 2a5564b

@ti-chi-bot ti-chi-bot merged commit 919e650 into pingcap:master Jun 10, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1192.

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

Successfully merging this pull request may close these issues.

add more pre-check to let lightning fail fast.
5 participants