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

planner: refactor some code related to binding #59868

Merged
merged 3 commits into from
Mar 4, 2025

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Mar 3, 2025

What problem does this PR solve?

Issue Number: ref #51347

Problem Summary: planner: refactor some code related to binding

What changed and how does it work?

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. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 3, 2025
Copy link

tiprow bot commented Mar 3, 2025

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

@Rustin170506 Rustin170506 requested a review from Copilot March 3, 2025 09:36

Choose a reason for hiding this comment

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

PR Overview

This PR refactors binding-related code by renaming the BindHandle API to BindingHandle and updating all associated usages. The changes include updates in domain, executor, planner, global handle implementation, and tests to ensure consistency in naming and behavior.

Reviewed Changes

File Description
pkg/bindinfo/utils.go Introduces a common callWithSCtx helper for executing SQL commands in a session.
pkg/domain/domain.go Updates domain methods and variable registrations to use BindingHandle.
pkg/executor/bind.go & pkg/executor/show.go Updates binding operations to reference BindingHandle instead of BindHandle.
pkg/planner/optimize.go Refactors global binding handle retrieval to use the new BindingHandle API.
pkg/bindinfo/global_handle.go Replaces the internal callWithSCtx method with the external version and updates logging.
pkg/bindinfo/global_handle_test.go Renames usage of BindHandle to BindingHandle in tests for consistency.
pkg/domain/db_test.go Updates comments to reflect the new BindingHandle naming.

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

pkg/bindinfo/global_handle.go:172

  • Verify that replacing the internal 'h.callWithSCtx' with the external callWithSCtx function correctly handles the session pool and transaction wrapping for all execution paths.
err = callWithSCtx(h.sPool, false, func(sctx sessionctx.Context) error {

pkg/bindinfo/global_handle.go:152

  • [nitpick] Ensure that the updated log message 'BindingHandle.Update' aligns with the new API naming convention across the codebase and that it properly communicates the context of the warning.
bindingLogger().Warn("BindingHandle.Update", zap.Error(err))

pkg/executor/bind.go:70

  • [nitpick] Confirm that updating the function call to use 'BindingHandle' delivers equivalent behavior to the previous 'BindHandle' implementation, particularly for binding deletion logic.
affectedRows, err := domain.GetDomain(e.Ctx()).BindingHandle().DropGlobalBinding([]string{e.details[0].SQLDigest})
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 3, 2025
@D3Hunter
Copy link
Contributor

D3Hunter commented Mar 3, 2025

/approve

for domain

@ti-chi-bot ti-chi-bot bot added the approved label Mar 3, 2025
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 85.96491% with 8 lines in your changes missing coverage. Please review.

Project coverage is 74.8936%. Comparing base (448649e) to head (6a48619).
Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59868        +/-   ##
================================================
+ Coverage   72.9395%   74.8936%   +1.9541%     
================================================
  Files          1699       1746        +47     
  Lines        469556     478620      +9064     
================================================
+ Hits         342492     358456     +15964     
+ Misses       105948      97595      -8353     
- Partials      21116      22569      +1453     
Flag Coverage Δ
integration 49.1222% <61.4035%> (?)
unit 72.2422% <85.9649%> (+0.0937%) ⬆️

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

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

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 3, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 3, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 3, 2025

/test unit-test

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 3, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 3, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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 Mar 3, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 3, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 3, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 4, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 4, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 4, 2025

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Mar 4, 2025
Copy link

ti-chi-bot bot commented Mar 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, D3Hunter, hawkingrei

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 Mar 4, 2025
Copy link

ti-chi-bot bot commented Mar 4, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-03 09:48:52.739555691 +0000 UTC m=+262245.868475436: ☑️ agreed by AilinKid.
  • 2025-03-04 01:38:52.404568499 +0000 UTC m=+319245.533488242: ☑️ agreed by hawkingrei.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 4, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 4, 2025

@qw4990: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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 b500d9e into pingcap:master Mar 4, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

4 participants