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: add complex unit tests for lightning post-import conflict detection "replace" mode #48514

Merged
merged 5 commits into from
Nov 22, 2023

Conversation

lyzx2001
Copy link
Contributor

@lyzx2001 lyzx2001 commented Nov 10, 2023

What problem does this PR solve?

Issue Number: ref #45774

Problem Summary:

Currently lightning only supports "remove" mode for post-import conflict detection, but many customers request lightning to support "replace" mode for lightning post-import conflict detection.

We would like to support "replace" mode for lightning post-import conflict detection:
To resolve rows with conflict, instead of deleting all the rows that are engaged in conflict (the algorithm for remove), we delete some of the rows with conflict and reserve other rows that can be kept and not cause conflict anymore. Under this circumstance, we only delete the necessary rows to resolve conflicts, so that we can keep more original rows than remove mode as long as the conflicts are resolved.

The algorithms for index KV checking is contained in #45926

The algorithms for data KV checking is contained in #46763

The integration tests are contained in #47460

This PR contains complex unit tests to test the correctness and performance of the algorithms.

What is changed and how it works?

Demo code for 'replace' mode of lightning post-import conflict detection:

https://github.com/lyzx2001/tidb-conflict-replace

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/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. labels Nov 10, 2023
Copy link

tiprow bot commented Nov 10, 2023

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 Nov 10, 2023

Codecov Report

Merging #48514 (1eb2953) into master (d2c0c6e) will increase coverage by 1.6709%.
Report is 138 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48514        +/-   ##
================================================
+ Coverage   71.4920%   73.1630%   +1.6709%     
================================================
  Files          1402       1435        +33     
  Lines        406343     418251     +11908     
================================================
+ Hits         290503     306005     +15502     
+ Misses        96004      93366      -2638     
+ Partials      19836      18880       -956     
Flag Coverage Δ
integration 44.1767% <ø> (?)
unit 71.6351% <ø> (+0.1430%) ⬆️

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

Components Coverage Δ
dumpling 54.1220% <ø> (+0.1345%) ⬆️
parser ∅ <ø> (∅)
br 49.0585% <ø> (-3.8596%) ⬇️

@lyzx2001 lyzx2001 changed the title [WIP] lightning: add complex unit tests for lightning post-import conflict detection "replace" mode lightning: add complex unit tests for lightning post-import conflict detection "replace" mode Nov 15, 2023
@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 Nov 15, 2023
@lyzx2001
Copy link
Contributor Author

/cc @lance6716

@ti-chi-bot ti-chi-bot bot requested a review from lance6716 November 15, 2023 05:40
require.NoError(t, err)
mockSctx := mock.NewContext()
mockSctx.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOff
info, err := ddl.MockTableInfo(mockSctx, node[0].(*ast.CreateTableStmt), 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
info, err := ddl.MockTableInfo(mockSctx, node[0].(*ast.CreateTableStmt), 1)
info, err := ddl.MockTableInfo(mockSctx, node[0].(*ast.CreateTableStmt), 108)

and we can delete line 261.

Also for other tests

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 21, 2023
@lyzx2001
Copy link
Contributor Author

/cc @D3Hunter

@ti-chi-bot ti-chi-bot bot requested a review from D3Hunter November 21, 2023 03:10
Copy link

ti-chi-bot bot commented Nov 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 22, 2023
Copy link

ti-chi-bot bot commented Nov 22, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-21 02:59:23.090254827 +0000 UTC m=+286791.755481022: ☑️ agreed by lance6716.
  • 2023-11-22 06:39:45.57315498 +0000 UTC m=+386414.238381177: ☑️ agreed by D3Hunter.

Copy link

tiprow bot commented Nov 22, 2023

@lyzx2001: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test 1eb2953 link true /test tiprow_fast_test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit c467718 into pingcap:master Nov 22, 2023
18 of 20 checks passed
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.

3 participants