Skip to content

Conversation

River2000i
Copy link
Contributor

@River2000i River2000i commented May 26, 2025

What problem does this PR solve?

Issue Number: close #61321

Problem Summary: truncate table\truncate partition\add partition use incorrect session context

What changed and how does it work?

get tidb_scatter_region from executor session context

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-tests-checked do-not-merge/needs-triage-completed 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. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 26, 2025
Copy link

ti-chi-bot bot commented May 26, 2025

Hi @River2000i. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

Copy link

tiprow bot commented May 26, 2025

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

@Benjamin2037
Copy link
Collaborator

Benjamin2037 commented May 26, 2025

Please make sure to add testcases to check that the system variable can be set and gets the correct value。

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2025
@River2000i River2000i changed the title [WIP]ddl: get scatter variable from executor session context ddl: get scatter variable from executor session context May 27, 2025
@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 May 27, 2025
func getScatterScopeFromSessionctx(sctx sessionctx.Context) string {
var scatterScope string
val, ok := sctx.GetSessionVars().GetSystemVar(vardef.TiDBScatterRegion)
if !ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What situation will cause !ok?

Copy link
Contributor Author

@River2000i River2000i May 27, 2025

Choose a reason for hiding this comment

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

image
If the variable didn't set by user, it will return !ok

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then I think there should not output Warn("get system variable met problem, won't scatter region"), Just one info, the system var did not be set, use the default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in dc069d3

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we use global setting if not set in session level?

Comment on lines 26 to 29
// FullMode is a flag identify it should be run in full mode.
// In full mode, the test will run all the cases.
var FullMode = flag.Bool("full-mode", false, "whether tests run in full mode")

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
// FullMode is a flag identify it should be run in full mode.
// In full mode, the test will run all the cases.
var FullMode = flag.Bool("full-mode", false, "whether tests run in full mode")

No usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, remove 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.

@Benjamin2037
Copy link
Collaborator

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. do-not-merge/needs-triage-completed labels May 27, 2025
Copy link
Collaborator

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

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 27, 2025
Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 98.11321% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.8800%. Comparing base (3634a3c) to head (d905f8b).
Report is 21 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61331        +/-   ##
================================================
+ Coverage   73.1772%   74.8800%   +1.7027%     
================================================
  Files          1726       1748        +22     
  Lines        478575     491660     +13085     
================================================
+ Hits         350208     368155     +17947     
+ Misses       106896     100497      -6399     
- Partials      21471      23008      +1537     
Flag Coverage Δ
integration 48.7887% <86.7924%> (?)
unit 72.4694% <98.1132%> (+0.0231%) ⬆️

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

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 61.3035% <ø> (+13.7304%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 28, 2025
@Benjamin2037 Benjamin2037 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label May 28, 2025
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 28, 2025
@River2000i
Copy link
Contributor Author

/retest

@Benjamin2037
Copy link
Collaborator

shouldn't we use global setting if not set in session level?

I think it's not reasonable that user didn't set session level variable but we use global level. Since we need to keep the same session level variable with user session

so what's the value if user session haven't set it, the value of the global one?

it will use "", which means not scatter region

What if user set global variable,but not set session level,then get session level variable will get global level value, right?

@River2000i
Copy link
Contributor Author

/retest

@Benjamin2037 Benjamin2037 requested a review from tangenta May 28, 2025 14:29
Copy link
Contributor

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

Comment on lines 1325 to 1328
var scatterScope string
if val, ok := jobW.GetSessionVars(vardef.TiDBScatterRegion); ok {
scatterScope = val
}
Copy link
Contributor

Choose a reason for hiding this comment

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

only need get once

Copy link

ti-chi-bot bot commented May 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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 May 28, 2025
Copy link

ti-chi-bot bot commented May 28, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-27 11:45:25.038452015 +0000 UTC m=+355855.410239461: ☑️ agreed by Benjamin2037.
  • 2025-05-28 14:46:07.555526241 +0000 UTC m=+30188.617543862: ☑️ agreed by D3Hunter.

@River2000i
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 May 28, 2025
@ti-chi-bot ti-chi-bot bot merged commit eeccd2e into pingcap:master May 28, 2025
27 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 28, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #61388.
But this PR has conflicts, please resolve them!

@River2000i River2000i deleted the fix61321 branch May 29, 2025 01:10
hawkingrei pushed a commit to hawkingrei/tidb that referenced this pull request May 29, 2025
OliverS929 added a commit to OliverS929/tidb that referenced this pull request Jul 2, 2025
…context (pingcap#61331)"" because it has multiple dependent commits.

This reverts commit 885f1ef.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ddl: the use of sys var tidb_scatter_region seems incorrect
5 participants