tidb icon indicating copy to clipboard operation
tidb copied to clipboard

executor: fix the issue that `INSERT IGNORE` doesn't lock the parent table

Open YangKeao opened this issue 1 year ago • 6 comments

What problem does this PR solve?

Issue Number: close #56655

Problem Summary:

INSERT IGNORE cannot lock the rows in parent, so the constraint may be broken.

What changed and how does it work?

Try to lock the rows even when the toBeCheckedKeys and toBeCheckedPrefixKeys are empty.

Check List

Tests

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

Release note

None

YangKeao avatar Oct 15 '24 13:10 YangKeao

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 56.2956%. Comparing base (49c3eba) to head (5179c92). Report is 1 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #56661         +/-   ##
=================================================
- Coverage   73.2689%   56.2956%   -16.9733%     
=================================================
  Files          1650       1776        +126     
  Lines        455646     634548     +178902     
=================================================
+ Hits         333847     357223      +23376     
- Misses       101279     253233     +151954     
- Partials      20520      24092       +3572     
Flag Coverage Δ
integration 37.0345% <100.0000%> (?)
unit 72.5107% <100.0000%> (-0.0485%) :arrow_down:

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 52.6262% <ø> (+6.6255%) :arrow_up:

codecov[bot] avatar Oct 15 '24 13:10 codecov[bot]

/retest

YangKeao avatar Oct 15 '24 14:10 YangKeao

/retest

YangKeao avatar Oct 17 '24 02:10 YangKeao

run test [planner/core/indexmerge_path] err: sql:explain select * from t use index (iad) where a = 1;: failed to run query 
"explain select * from t use index (iad) where a = 1;" 
 around line 233, 
we need(299):
explain select * from t use index (iad) where a = 1;
id      estRows task    access object   operator info
TableReader_7   1.00    root            data:Selection_6
└─Selection_6   1.00    cop[tikv]               eq(planner__core__indexmerge_path.t.a, 1)
  └─TableFullScan_5     2.00    cop[tikv]       table:t keep order:false
explain select * fro
but got(299):
explain select * from t use index (iad) where a = 1;
id      estRows task    access object   operator info
TableReader_7   10.00   root            data:Selection_6
└─Selection_6   10.00   cop[tikv]               eq(planner__core__indexmerge_path.t.a, 1)
  └─TableFullScan_5     10000.00        cop[tikv]       table:t keep order:false, stats:pseudo

This test failure cannot be reproduced locally :thinking: . Investigating.

YangKeao avatar Oct 17 '24 03:10 YangKeao

/retest

YangKeao avatar Oct 21 '24 07:10 YangKeao

/retest

YangKeao avatar Oct 23 '24 09:10 YangKeao

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, crazycs520

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:
  • ~~OWNERS~~ [bb7133,crazycs520]

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[bot] avatar Oct 29 '24 18:10 ti-chi-bot[bot]

[LGTM Timeline notifier]

Timeline:

  • 2024-10-28 06:12:21.410051194 +0000 UTC m=+243854.249206740: :ballot_box_with_check: agreed by crazycs520.
  • 2024-10-29 18:35:36.774626435 +0000 UTC m=+374849.613781981: :ballot_box_with_check: agreed by bb7133.

ti-chi-bot[bot] avatar Oct 29 '24 18:10 ti-chi-bot[bot]

/retest

YangKeao avatar Oct 30 '24 04:10 YangKeao

/retest

YangKeao avatar Oct 30 '24 07:10 YangKeao

/retest

YangKeao avatar Oct 31 '24 04:10 YangKeao