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

table: fix lazy check key condition in index.Create and AddRecord #51982

Closed

Conversation

ekexium
Copy link
Contributor

@ekexium ekexium commented Mar 21, 2024

What problem does this PR solve?

Issue Number: ref #50215

Problem Summary:

INSERT IGNORE ... ON DUPLICATE UPDATE ... could return a Duplicate entry error for a Pipelined-DML, because it does lazy checks in the places modified by this PR, and the error is returned when committing. It does not break data constraints, but we expect that such error should be ignored because we specify IGNORE, as in a normal DML.

What changed and how does it work?

Change the condition of lazy check: do not let pipelined DML enforce lazy checks. If the executor think this is the place to do txn.Get, then do it.
Note that we enforce Pipelined-DML to have tidb_constraint_check_in_place=false.

tidb/pkg/session/session.go

Lines 4346 to 4349 in e349451

if s.GetSessionVars().ConstraintCheckInPlace {
// we enforce that pipelined DML must lazily check key.
return false
}

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 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 21, 2024
Copy link

tiprow bot commented Mar 21, 2024

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

@ekexium ekexium force-pushed the pipelined-dml-fix-ignore-on-update branch from aff0b98 to 482a01e Compare March 21, 2024 07:44
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Merging #51982 (882a912) into master (96f1078) will decrease coverage by 1.0282%.
Report is 4 commits behind head on master.
The diff coverage is 100.0000%.

❗ Current head 882a912 differs from pull request most recent head ce71241. Consider uploading reports for the commit ce71241 to get more accurate results

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #51982        +/-   ##
================================================
- Coverage   72.3846%   71.3565%   -1.0282%     
================================================
  Files          1477       1562        +85     
  Lines        427998     478528     +50530     
================================================
+ Hits         309805     341461     +31656     
- Misses        98950     116269     +17319     
- Partials      19243      20798      +1555     
Flag Coverage Δ
integration 48.6474% <100.0000%> (?)
unit 71.1930% <100.0000%> (-0.0675%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 28.2862% <ø> (-12.9332%) ⬇️

Copy link

ti-chi-bot bot commented Mar 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk

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 approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 21, 2024
Copy link

ti-chi-bot bot commented Mar 21, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-21 08:24:30.618465711 +0000 UTC m=+1537897.640712102: ☑️ agreed by cfzjywxk.

Copy link
Contributor

@you06 you06 left a comment

Choose a reason for hiding this comment

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

The insert statement will get each unique/primary key in AddRecord then, shall we manually set PresumeKeyNotExists for simple insert statement?

Rest LGTM.

@cfzjywxk
Copy link
Contributor

The insert statement will get each unique/primary key in AddRecord then, shall we manually set PresumeKeyNotExists for simple insert statement?

Rest LGTM.

@you06 Do you mean simple INSERT statement using pipelined-dml mode?

@you06
Copy link
Contributor

you06 commented Mar 21, 2024

@you06 Do you mean simple INSERT statement using pipelined-dml mode?

@cfzjywxk sorry mistake, it happens in insert-on-duplicate-key-update, run go test ./tests/realtikvtest/pipelineddmltest --tags=intest -run TestPipelinedDMLInsertRPC can fail now.

@ekexium
Copy link
Contributor Author

ekexium commented Mar 21, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2024
@ekexium
Copy link
Contributor Author

ekexium commented Apr 24, 2024

/retest

Copy link

tiprow bot commented Apr 24, 2024

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

In response to this:

/retest

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

ti-chi-bot bot commented Apr 24, 2024

@ekexium: 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
idc-jenkins-ci-tidb/check_dev_2 882a912 link true /test check-dev2

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 added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 24, 2024
@ekexium
Copy link
Contributor Author

ekexium commented Apr 24, 2024

Won't fix this because it will inevitably introduce notable performance overhead. We may have to keep this behavior for pipelined DML

@ekexium ekexium closed this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants