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

expression: Add failpoint to force pushdown expression to tikv for debug usage #59765

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

yibin87
Copy link
Contributor

@yibin87 yibin87 commented Feb 26, 2025

What problem does this PR solve?

Issue Number: ref #51876

Problem Summary:
To debug expression behaviors not consistent between tidb and tikv, we need to force push down these projection expressions to tikv ignoring cost consideration. So we add a failpoint here to help debug tikv expression behavior.

What changed and how does it work?

mysql> create table t0(a int, b int);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t0 values(3, 20);
Query OK, 1 row affected (0.01 sec)

mysql> insert into t0 values(29, 30);
Query OK, 1 row affected (0.01 sec)

mysql> explain select a-b, a+b from t0;
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
| id                      | estRows  | task      | access object | operator info                                                               |
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
| Projection_3            | 10000.00 | root      |               | minus(test.t0.a, test.t0.b)->Column#4, plus(test.t0.a, test.t0.b)->Column#5 |
| └─TableReader_5         | 10000.00 | root      |               | data:TableFullScan_4                                                        |
|   └─TableFullScan_4     | 10000.00 | cop[tikv] | table:t0      | keep order:false, stats:pseudo                                              |
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
3 rows in set (0.00 sec)

Now, after build tidb with failpoint enable: "make failpoint-enable"
export GO_FAILPOINTS="github.com/pingcap/tidb/pkg/expression/forcePushDownTiKV=return(true)"
start tidb server, then a+b and a-b will be pushed down to tikv side:

mysql> explain select a-b, a+b from t0;
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
| id                      | estRows  | task      | access object | operator info                                                               |
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
| TableReader_8           | 10000.00 | root      |               | data:Projection_4                                                           |
| └─Projection_4          | 10000.00 | cop[tikv] |               | minus(test.t0.a, test.t0.b)->Column#4, plus(test.t0.a, test.t0.b)->Column#5 |
|   └─TableFullScan_7     | 10000.00 | cop[tikv] | table:t0      | keep order:false, stats:pseudo                                              |
+-------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------+
3 rows in set (0.00 sec)

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 26, 2025
Copy link

tiprow bot commented Feb 26, 2025

Hi @yibin87. 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-sigs/prow repository.

@yibin87
Copy link
Contributor Author

yibin87 commented Feb 26, 2025

/cc @windtalker @xzhangxian1008

Copy link
Contributor

@xzhangxian1008 xzhangxian1008 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Feb 26, 2025
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 73.8347%. Comparing base (15f3c28) to head (db2fc85).
Report is 9 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59765        +/-   ##
================================================
+ Coverage   72.9819%   73.8347%   +0.8527%     
================================================
  Files          1698       1699         +1     
  Lines        469046     472951      +3905     
================================================
+ Hits         342319     349202      +6883     
+ Misses       105654     102733      -2921     
+ Partials      21073      21016        -57     
Flag Coverage Δ
integration 43.2976% <25.0000%> (?)
unit 72.6442% <25.0000%> (+0.4630%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.0647% <ø> (+0.0394%) ⬆️

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

ti-chi-bot bot commented Feb 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: windtalker, xzhangxian1008

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 26, 2025
Copy link

ti-chi-bot bot commented Feb 26, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-02-26 02:38:18.217800855 +0000 UTC m=+409846.170959122: ☑️ agreed by xzhangxian1008.
  • 2025-02-26 09:30:49.126824951 +0000 UTC m=+434597.079983210: ☑️ agreed by windtalker.

@ti-chi-bot ti-chi-bot bot merged commit f689bd6 into pingcap:master Feb 26, 2025
24 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants