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: remove post-import conflict detection "remove" and "record" semantic, and add "error" semantic #50806

Merged
merged 23 commits into from
Feb 19, 2024

Conversation

lyzx2001
Copy link
Contributor

@lyzx2001 lyzx2001 commented Jan 30, 2024

What problem does this PR solve?

Issue Number: ref #51036

Problem Summary:
Merge preprocess duplicate detection and post-import conflict detection.

What changed and how does it work?

Remove post-import conflict detection "remove" and "record" semantic, and add "error" semantic.

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

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 30, 2024
Copy link

tiprow bot commented Jan 30, 2024

Hi @lyzx2001. 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.

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Merging #50806 (df67d8d) into master (51e1e13) will increase coverage by 3.3291%.
Report is 113 commits behind head on master.
The diff coverage is 55.9523%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #50806        +/-   ##
================================================
+ Coverage   70.4926%   73.8217%   +3.3291%     
================================================
  Files          1463       1469         +6     
  Lines        433262     453671     +20409     
================================================
+ Hits         305418     334908     +29490     
+ Misses       108580      98093     -10487     
- Partials      19264      20670      +1406     
Flag Coverage Δ
integration 50.9058% <27.3809%> (?)
unit 70.3137% <51.1904%> (+0.0289%) ⬆️

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

Components Coverage Δ
dumpling 54.2940% <ø> (ø)
parser ∅ <ø> (∅)
br 54.9448% <55.9523%> (+9.2085%) ⬆️

@lyzx2001 lyzx2001 changed the title [WIP] lightning: merge preprocess duplicate detection and post-import conflict detection lightning: remove post-import conflict detection "remove" and "record" semantic Feb 7, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 7, 2024
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/needs-linked-issue labels Feb 7, 2024
@lyzx2001
Copy link
Contributor Author

lyzx2001 commented Feb 7, 2024

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 7, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

lyzx2001 commented Feb 7, 2024

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 7, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

lyzx2001 commented Feb 7, 2024

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 7, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

lyzx2001 commented Feb 7, 2024

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 7, 2024

@lyzx2001: 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.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 7, 2024
@lyzx2001
Copy link
Contributor Author

lyzx2001 commented Feb 7, 2024

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 7, 2024

@lyzx2001: 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
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

/hold

need to address comment

@ti-chi-bot ti-chi-bot bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 18, 2024
Copy link

ti-chi-bot bot commented Feb 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-02-18 08:49:40.342214893 +0000 UTC m=+174269.089837996: ☑️ agreed by D3Hunter.
  • 2024-02-18 09:10:18.365572226 +0000 UTC m=+175507.113195337: ☑️ agreed by lance6716.

@lyzx2001
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 18, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 18, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 18, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

/test pull-lightning-integration-test

Copy link

tiprow bot commented Feb 18, 2024

@lyzx2001: 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.

@lyzx2001
Copy link
Contributor Author

/cc @3pointer

@ti-chi-bot ti-chi-bot bot requested a review from 3pointer February 19, 2024 03:49
Copy link
Contributor

@lance6716 lance6716 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

_, gCtx := errgroup.WithContext(ctx)

kvRows, err := em.db.QueryContext(
gCtx, common.SprintfWithIdentifiers(selectConflictKeysCountError, em.schema),
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to query the count(*). we can query all data and check if result is empty

// ResolveConflictKeysError query all conflicting rows (handle and their
// values) from the current error report and return error
// if the number of the conflicting rows is larger than 0.
func (em *ErrorManager) ResolveConflictKeysError(
Copy link
Contributor

Choose a reason for hiding this comment

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

it's better we implement the "error" setting in dupeController.CollectRemoteDuplicateRows. That function will fail earlier when see the first error. In this location we will record all errors which may cost a lot.

You can open another PR to do 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.

OK. Will implement in the next PR.

! run_lightning --backend local --config "${mydir}/config.toml"
[ $? -eq 0 ]

tail -n 10 $TEST_DIR/lightning.log | grep "ERROR" | tail -n 1 | grep -Fq "[Lightning:Restore:ErrFoundDuplicateKey]found duplicate key"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also check the output key is human readable? also ask PM what's the expected format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I conform to the output for the error mode of preprocess detection

if d.option.ReportErrOnDup {
dupKey := make([]byte, len(d.curKey))
dupVal := make([]byte, len(val))
copy(dupKey, d.curKey)
copy(dupVal, d.curVal)
return nil, nil, false, ErrFoundDuplicateKeys.FastGenByArgs(dupKey, dupVal)
}

I think users want unified output no matter the conflicts come from preprocess detection or post-import detection.
Let me check with PM for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the output looks like this

[error="[Lightning:Restore:ErrFoundDuplicateKey]found duplicate key 't\ufffd\u0000\u0000\u0000\u0000\u0000\u0000l_r\ufffd\u0000\u0000\u0000\u0000\u0000\u0000\u0001', value '\ufffd\u0000\u0002\u0000\u0000\u0000\u0002\u0003\u0001\u0000\u0006\u0000\u00061.csv'"]

Copy link
Contributor

Choose a reason for hiding this comment

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

"error" is only internally used before, it does not consider human-readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

DDL uses "error" option before, and has extra work to extract the data, like

			if common.ErrFoundDuplicateKeys.Equal(err) {
				err = convertToKeyExistsErr(err, indexInfo, tbl.Meta())
			}

We can mimic it or we directly read other fields from the conflict error table and display them to user. Please be careful do not break DDL's behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will address in next PR.

@lyzx2001
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 19, 2024
@lyzx2001
Copy link
Contributor Author

/cc @Leavrth

@ti-chi-bot ti-chi-bot bot requested a review from Leavrth February 19, 2024 04:45
Copy link

ti-chi-bot bot commented Feb 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716, Leavrth

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants