Skip to content

session: rename and unify location of interfaces, and some refactor#62498

Merged
ti-chi-bot[bot] merged 5 commits into
pingcap:masterfrom
D3Hunter:move-session-api
Jul 22, 2025
Merged

session: rename and unify location of interfaces, and some refactor#62498
ti-chi-bot[bot] merged 5 commits into
pingcap:masterfrom
D3Hunter:move-session-api

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

What changed and how does it work?

  • rename session/types pkg as session/sessionapi, types is not a good name to describe what it does
  • abstract common part of planctx.PlanContext and sessionctx.Context. previously, if I want to add a API to both of them, i have to edit 2 place.
  • decouple sessionctx.Context and SessionStatesHandler, sessionctx.Context is for calling related handlers, but itself is not one of them.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test. THIS PR ONLY RENAME OR MOVE SOME INTERFACE, NO LOGIC CHANGE
    • 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Jul 18, 2025
@tiprow

tiprow Bot commented Jul 18, 2025

Copy link
Copy Markdown

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

Details

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.

@D3Hunter D3Hunter changed the title session: rename and unify location of interfaces, and some refactor [WIP]session: rename and unify location of interfaces, and some refactor Jul 18, 2025
@ti-chi-bot ti-chi-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 18, 2025
@codecov

codecov Bot commented Jul 18, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.87156% with 9 lines in your changes missing coverage. Please review.

Project coverage is 75.2744%. Comparing base (e2a9f04) to head (24c03c6).
Report is 18 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #62498        +/-   ##
================================================
+ Coverage   72.8290%   75.2744%   +2.4454%     
================================================
  Files          1760       1808        +48     
  Lines        485971     498129     +12158     
================================================
+ Hits         353928     374964     +21036     
+ Misses       110406     100131     -10275     
- Partials      21637      23034      +1397     
Flag Coverage Δ
integration 49.0187% <11.5207%> (?)
unit 72.6174% <95.8715%> (+0.5084%) ⬆️

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

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1643% <66.6666%> (+16.8416%) ⬆️
🚀 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.

Comment thread pkg/executor/show.go
func (e *ShowExec) fetchShowSessionStates(ctx context.Context) error {
sessionStates := &sessionstates.SessionStates{}
err := e.Ctx().EncodeSessionStates(ctx, e.Ctx(), sessionStates)
err := e.Ctx().EncodeStates(ctx, sessionStates)

@D3Hunter D3Hunter Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we separate the main caller, *session.session, and the handlers, such as TiDBContext and sessionBindingHandle

Comment thread pkg/executor/simple.go
return errors.Trace(err)
}
return e.Ctx().DecodeSessionStates(ctx, e.Ctx(), &sessionStates)
return e.Ctx().DecodeStates(ctx, &sessionStates)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

here too

Comment thread pkg/sessionctx/context.go
Comment on lines +83 to +85
EncodeStates(context.Context, *sessionstates.SessionStates) error
// DecodeStates decodes a map into session states.
DecodeStates(context.Context, *sessionstates.SessionStates) error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

those 2 are added to difference with SessionStatesHandler

@D3Hunter D3Hunter changed the title [WIP]session: rename and unify location of interfaces, and some refactor session: rename and unify location of interfaces, and some refactor Jul 21, 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 Jul 21, 2025
Comment thread pkg/sessionctx/context.go
type Context interface {
SessionStatesHandler
contextutil.ValueStoreContext
planctx.Common

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need planctx.Common here? A user can call Context. GetPlanCtx()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sessionctx.Context need those API defined in planctx.Common which are shared with PlanCtx, i just unify the definition of those APIs

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 21, 2025
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 22, 2025
@ti-chi-bot

ti-chi-bot Bot commented Jul 22, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-07-21 09:08:07.011943475 +0000 UTC m=+228923.933087459: ☑️ agreed by lcwangchao.
  • 2025-07-22 02:27:00.752615899 +0000 UTC m=+45177.490042107: ☑️ agreed by tangenta.

@ti-chi-bot

ti-chi-bot Bot commented Jul 22, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lcwangchao, Leavrth, tangenta, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 the approved label Jul 22, 2025
@ti-chi-bot ti-chi-bot Bot merged commit 5ae6ad6 into pingcap:master Jul 22, 2025
36 of 38 checks passed
@D3Hunter D3Hunter deleted the move-session-api branch July 22, 2025 07:48
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. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants