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

*: isolate more variables for runWithSystemSession #54791

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

lance6716
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #54343

Problem Summary:

What changed and how does it work?

as title

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-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels Jul 22, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Jul 22, 2024
@ti-chi-bot ti-chi-bot bot added sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 22, 2024
Copy link

tiprow bot commented Jul 22, 2024

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

@@ -1466,6 +1466,11 @@ func init() {
return nil, err
}

tm := sessiontxn.GetTxnManager(sctx)
err = tm.EnterNewTxn(ctx, &sessiontxn.EnterNewTxnRequest{})
Copy link
Contributor

Choose a reason for hiding this comment

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

should we commit or rollback before return?

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.4529%. Comparing base (07f7774) to head (012e6bb).
Report is 741 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54791         +/-   ##
=================================================
- Coverage   74.7413%   56.4529%   -18.2884%     
=================================================
  Files          1555       1680        +125     
  Lines        363372     616377     +253005     
=================================================
+ Hits         271589     347963      +76374     
- Misses        72138     244974     +172836     
- Partials      19645      23440       +3795     
Flag Coverage Δ
integration 37.9157% <40.0000%> (?)
unit 72.1719% <40.0000%> (-1.4941%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 52.3833% <ø> (+4.7078%) ⬆️

Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jul 23, 2024

@lance6716: 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-sigs/prow repository.

Signed-off-by: lance6716 <[email protected]>
@lance6716
Copy link
Contributor Author

/check-issue-triage-complete

@lance6716 lance6716 changed the title *: EnterNewTxn before EvalSubqueryFirstRow *: isolated more variables for runWithSystemSession Jul 23, 2024
@lance6716 lance6716 changed the title *: isolated more variables for runWithSystemSession *: isolate more variables for runWithSystemSession Jul 23, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 23, 2024
@@ -898,6 +897,7 @@ func (e *hugeMemTableRetriever) dataForColumnsInTable(ctx context.Context, sctx
internalCtx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnOthers)
// Build plan is not thread safe, there will be concurrency on sessionctx.
if err := runWithSystemSession(internalCtx, sctx, func(s sessionctx.Context) error {
is := sessiontxn.GetTxnManager(s).GetTxnInfoSchema()
Copy link
Contributor

Choose a reason for hiding this comment

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

is this where the fix is, replace with another session ctx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original error is "ctx provider not found", but it's overwritten #54809. So the first fix is add sessiontxn.NewTxn.

Then another problem is the system session still uses the is captured by closure, which has conflict with user session. So moving it here.

@@ -2377,5 +2378,12 @@ func runWithSystemSession(ctx context.Context, sctx sessionctx.Context, fn func(
return err
}
defer b.ReleaseSysSession(ctx, sysCtx)
if err = sessiontxn.NewTxn(ctx, sysCtx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add some comment on why we must open an explicit txn

@lance6716
Copy link
Contributor Author

/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 Jul 23, 2024
Signed-off-by: lance6716 <[email protected]>
@lance6716
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 Jul 23, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 23, 2024
Copy link

ti-chi-bot bot commented Jul 23, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-23 04:25:37.773574984 +0000 UTC m=+932759.764516455: ☑️ agreed by tangenta.
  • 2024-07-23 06:15:10.350758657 +0000 UTC m=+939332.341700126: ☑️ agreed by D3Hunter.

@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jul 23, 2024

@lance6716: 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-sigs/prow repository.

@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jul 23, 2024

@lance6716: 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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit b19a918 into pingcap:master Jul 23, 2024
23 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #54843.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 23, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jul 26, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #54937.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 26, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Jul 26, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #54949.

@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Oct 28, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #56902.

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-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
5 participants