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: skip CREATE DATABASE when downstream exists, and return error when parse failed #51801

Merged
merged 12 commits into from
Mar 18, 2024

Conversation

lance6716
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #51800

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 15, 2024
Copy link

tiprow bot commented Mar 15, 2024

Hi @lance6716. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lance6716
Copy link
Contributor Author

/check-issue-triage-complete

Signed-off-by: lance6716 <lance6716@gmail.com>
@@ -630,7 +630,8 @@ func (worker *restoreSchemaWorker) addJob(sqlStr string, job *schemaJob) error {
zap.String("table", job.tblName),
zap.String("statement", sqlStr),
zap.Error(err))
job.stmts = []string{sqlStr}
useStmt := common.SprintfWithIdentifiers("USE %s", job.dbName)
job.stmts = []string{useStmt, sqlStr}
Copy link
Contributor

@D3Hunter D3Hunter Mar 15, 2024

Choose a reason for hiding this comment

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

we should return error if we cannot parse the sql, so user can see the real err that help diagnose. lightning version >= tidb-version in most case, so there shouldn't be cases that lightning cannot parse, but tidb can execute it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a cloud oncall, tiflow's version is lower than downstream TiDB

Copy link
Contributor

Choose a reason for hiding this comment

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

then we should update tiflow with latest tidb dependency

also the logic to use original sql is error prone when the unparsable sql already contains dbname that might be the one we want

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our rewrite logic will not change the error message if downstream can not execute them, the user still can see a meaningful error message which is reported by downstream TiDB's parser.

Copy link
Contributor

Choose a reason for hiding this comment

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

i mean when the sql is unparsable by tiflow, but ok for tidb, then we might created it in the wrong db

Copy link
Member

@okJiang okJiang Mar 15, 2024

Choose a reason for hiding this comment

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

I agree update tiflow with latest tidb dependency

But since we already support the function of executing raw SQL even if it cannot be parsed, I think this PR can be fixed as a bug. Unless we firmly decide to remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should remove the fallback logic if tiflow can be newer than downstream TiDB

Choose a reason for hiding this comment

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

I also agree with "update tiflow with latest tidb dependency"

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Merging #51801 (e60d60c) into master (c1e3dae) will decrease coverage by 16.2924%.
Report is 35 commits behind head on master.
The diff coverage is 73.6111%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #51801         +/-   ##
=================================================
- Coverage   70.7897%   54.4973%   -16.2924%     
=================================================
  Files          1476       1591        +115     
  Lines        437887     613441     +175554     
=================================================
+ Hits         309979     334309      +24330     
- Misses       108554     256574     +148020     
- Partials      19354      22558       +3204     
Flag Coverage Δ
integration 36.5703% <75.7575%> (?)
unit 70.4361% <41.6666%> (-0.1667%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.9072% <73.6111%> (+5.9493%) ⬆️

Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Mar 15, 2024

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-lightning-integration-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need a empty file in this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The run_lightning script needs a configuration file, otherwise it will report error. Empty file means default configuration.

Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 18, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Mar 18, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Mar 18, 2024

@lance6716: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test pull-lightning-integration-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lance6716 lance6716 changed the title lightning: fix "no database selected" when downstream is more capabile lightning: skip CREATE DATABASE when downstream has it, and return error when failed parse Mar 18, 2024
@lance6716 lance6716 changed the title lightning: skip CREATE DATABASE when downstream has it, and return error when failed parse lightning: skip CREATE DATABASE when downstream has it, and return error when parse failed Mar 18, 2024
@lance6716 lance6716 changed the title lightning: skip CREATE DATABASE when downstream has it, and return error when parse failed lightning: skip CREATE DATABASE when downstream exists, and return error when parse failed Mar 18, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 18, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 18, 2024
Copy link

ti-chi-bot bot commented Mar 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-18 08:10:59.985118392 +0000 UTC m=+1277887.007364779: ☑️ agreed by D3Hunter.
  • 2024-03-18 09:19:18.372643371 +0000 UTC m=+1281985.394889758: ☑️ agreed by okJiang.

Copy link

ti-chi-bot bot commented Mar 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, D3Hunter, okJiang

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Mar 18, 2024
@ti-chi-bot ti-chi-bot bot merged commit eea1213 into pingcap:master Mar 18, 2024
36 checks passed
@GMHDBJD
Copy link
Contributor

GMHDBJD commented Mar 25, 2024

/cherry-pick release-6.5

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Mar 25, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@GMHDBJD: new pull request created to branch release-6.5: #52065.

In response to this:

/cherry-pick release-6.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

ti-chi-bot bot pushed a commit that referenced this pull request Apr 2, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Apr 12, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #52586.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 12, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Apr 15, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label May 7, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 7, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #53070.

ti-chi-bot bot pushed a commit that referenced this pull request May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When lightning is less capabile than downstream, USE <database> may miss so failed with "no database selected"
8 participants