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

lighting: expose limited fields for kv.Session #55517

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

lcwangchao
Copy link
Collaborator

What problem does this PR solve?

Issue Number: ref #53388

What changed and how does it work?

This PR makes some changes to kv.Session to avoid expose all fields of sessionctx.Context. This approach can make developers more clear about what contexts are used in lightning and easier to check whether the mocked session have been constructed properly.

This PR makes the old implementation of sessionctx.Context private, and in the further PRs, we'll remove this private session struct.

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 20, 2024
Copy link

tiprow bot commented Aug 20, 2024

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

)

func TestSession(t *testing.T) {
session := kv.NewSessionCtx(&encode.SessionOptions{SQLMode: mysql.ModeNone, Timestamp: 1234567890}, log.L())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test is deleted because kv.NewSessionCtx is deleted

return &tidbEncoder{
mode: config.SQLMode,
tbl: config.Table,
se: se,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seems tidbEncoder.se is useless, just delete it.

@lcwangchao lcwangchao force-pushed the lightingse branch 3 times, most recently from c6aa732 to 2f874c9 Compare August 20, 2024 05:38
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 88.42105% with 11 lines in your changes missing coverage. Please review.

Project coverage is 74.8227%. Comparing base (509d1bd) to head (5400604).
Report is 17 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55517        +/-   ##
================================================
- Coverage   74.8899%   74.8227%   -0.0673%     
================================================
  Files          1576       1598        +22     
  Lines        365726     452241     +86515     
================================================
+ Hits         273892     338379     +64487     
- Misses        72057      92961     +20904     
- Partials      19777      20901      +1124     
Flag Coverage Δ
integration 50.7597% <82.1052%> (?)
unit 71.9746% <75.2688%> (-1.8865%) ⬇️

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

Components Coverage Δ
dumpling 52.9567% <ø> (-2.2327%) ⬇️
parser ∅ <ø> (∅)
br 51.8558% <ø> (+4.0577%) ⬆️

// transaction type and provides the session variables to the TiDB library
// optimized for Lightning.
type Session struct {
type session struct {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here I make the original session private because not all fields in sessionctx.Context will be used. The public
struct Session will wrap this session and provide some necessary methods.

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 this as code comment

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

pkg/lightning/backend/kv/session.go Outdated Show resolved Hide resolved
// transaction type and provides the session variables to the TiDB library
// optimized for Lightning.
type Session struct {
type session struct {
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 this as code comment

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 20, 2024
Copy link

ti-chi-bot bot commented Aug 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Aug 20, 2024
Copy link

ti-chi-bot bot commented Aug 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-20 09:16:12.129365635 +0000 UTC m=+256967.263815756: ☑️ agreed by D3Hunter.
  • 2024-08-20 09:21:01.522494436 +0000 UTC m=+257256.656944566: ☑️ agreed by tangenta.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Aug 20, 2024

@lcwangchao: 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.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Aug 20, 2024

@lcwangchao: 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.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Aug 20, 2024

@lcwangchao: 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 1f095a3 into pingcap:master Aug 20, 2024
22 checks passed
@lcwangchao lcwangchao deleted the lightingse branch August 20, 2024 14:35
breezewish added a commit that referenced this pull request Aug 21, 2024
…e-upstream

* origin/master:
  parser:  call `SetText` correctly for `CreateViewStmt` (#55520)
  lighting: expose limited fields for `kv.Session` (#55517)
  show: prefilter table name with like pattern and show full tables (#55396)
  Planner: Do not allow cardinality to go below 1 (#55242)
  *: replace maps.Copy which is for map clone with std maps.Clone (#55530)
  infoschema: add WithRefillOption for TableByName and TableByID (#55511)
  domain: change groupSize in splitForConcurrentFetch (#55518)
  ddl: fix resuming to wrong checkpoint when failed during adding index (#55506)
breezewish added a commit to breezewish/tidb that referenced this pull request Aug 21, 2024
…e-upstream

* origin/master:
  parser:  call `SetText` correctly for `CreateViewStmt` (pingcap#55520)
  lighting: expose limited fields for `kv.Session` (pingcap#55517)
  show: prefilter table name with like pattern and show full tables (pingcap#55396)
  Planner: Do not allow cardinality to go below 1 (pingcap#55242)
  *: replace maps.Copy which is for map clone with std maps.Clone (pingcap#55530)
  infoschema: add WithRefillOption for TableByName and TableByID (pingcap#55511)
  domain: change groupSize in splitForConcurrentFetch (pingcap#55518)
  ddl: fix resuming to wrong checkpoint when failed during adding index (pingcap#55506)

Signed-off-by: Wish <breezewish@outlook.com>
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants