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

lightning: do not output pre-check info when disable check-requirements #27934

Merged
merged 10 commits into from
Sep 22, 2021

Conversation

Little-Wallace
Copy link
Contributor

@Little-Wallace Little-Wallace commented Sep 9, 2021

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
Lightning will check some requirement and it may cause lightning can not run.

What is changed and how it works?

Part of pingcap/tiflow#5833

What's Changed:

  • do not output pre-check info when disable check-requirements
  • support SetAppLogger so that DM-worker can use lightning as a library.
  • return status of lightning so that DM-worker can judge how much data lightning has imported to TiKV.

How it Works:

Check List

Tests

  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

* fix output pre-check info even if user disable check-requirements.

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3pointer
  • 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 release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 9, 2021
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -92,8 +92,7 @@ func (rc *Controller) getClusterAvail(ctx context.Context) (uint64, error) {
return clusterAvail, nil
}

// ClusterResource check cluster has enough resource to import data. this test can by skipped.
func (rc *Controller) ClusterResource(ctx context.Context, localSource int64) error {
func (rc *Controller) clusterResource(ctx context.Context, localSource int64) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it's useful to keep the doc comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

br/pkg/lightning/lightning.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added status/LGT1 Indicates that a PR has LGTM 1. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Sep 15, 2021
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@@ -314,11 +314,20 @@ func (tr *TableRestore) restoreEngines(pCtx context.Context, rc *Controller, cp
dataWorker := rc.closedEngineLimit.Apply()
defer rc.closedEngineLimit.Recycle(dataWorker)
err = tr.importEngine(ctx, dataClosedEngine, rc, eid, ecp)
if rc.status != nil {
for _, chunk := range ecp.Chunks {
rc.status.FinishedFileSize.Add(chunk.FileMeta.FileSize)
Copy link
Contributor

@sleepymole sleepymole Sep 22, 2021

Choose a reason for hiding this comment

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

Multiple chunks may share a same file when we split large csv files. The correct value should be chunk.Chunk.EndOffset - chunk.Key.Offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if it started since a checkpoint, we shall calculate the total size rather than how much it does in this job.

}
if err != nil {
setError(err)
}
}(restoreWorker, engineID, engine)
} else {
for _, chunk := range engine.Chunks {
rc.status.FinishedFileSize.Add(chunk.FileMeta.FileSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -82,7 +82,7 @@ func (c *SimpleTemplate) Collect(t CheckType, passed bool, msg string) {
}

func (c *SimpleTemplate) Success() bool {
return c.warnFailedCount+c.criticalFailedCount == 0
return c.criticalFailedCount == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

// If the performance is not as expect or one of critical check not passed. it will stop import task.
Collect(t CheckType, passed bool, msg string)

If c.warnFailedCount > 0, the import task should also be failed. @3pointer PTAL

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@Little-Wallace
Copy link
Contributor Author

/run-check_dev_2

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
return errors.Trace(err)
}
if rc.cfg.App.CheckRequirements {
if err := rc.ClusterIsAvailable(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if !rc.cfg.App.CheckRequirements {

this line can be removed

}
}
}
if rc.tidbGlue.OwnsSQLExecutor() {

if rc.tidbGlue.OwnsSQLExecutor() && rc.cfg.App.CheckRequirements {
// print check info at any time.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

@3pointer 3pointer left a comment

Choose a reason for hiding this comment

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

rest LGTM

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 22, 2021
@Little-Wallace
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: aac4185

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 22, 2021
@ti-chi-bot ti-chi-bot merged commit 1e8b933 into pingcap:master Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants