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

table: Add GetStatisticsSupport and GetBinlogSupport for MutateContext #54832

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Jul 23, 2024

What problem does this PR solve?

Issue Number: ref #54397

Some fields/operations provided by MutateContext are optional. For example, binlog is not used in lighting import and all binlog operations should be skipped in this scene.

To make the MutateContext easy to construct and better decouple with sessionctx.Context. We can add some "optional" design for some fields or methods.

What changed and how does it work?

We name some operational information with "XXXSupport" and provide methods "GetXXXSupport" to return them. These methods return two values, the first value is the optional object implements XXXSupport and the second value is a boolean that indicates whether it is supported.

In this PR, two optional objects are defined to support binlog and statistics update:

// BinlogSupport is used for binlog operations
type BinlogSupport interface {
	// GetBinlogMutation returns a `binlog.TableMutation` object for a table.
	GetBinlogMutation(tblID int64) *binlog.TableMutation
}

// StatisticsSupport is used for statistics update operations.
type StatisticsSupport interface {
	// UpdatePhysicalTableDelta updates the physical table delta.
	UpdatePhysicalTableDelta(physicalTableID int64, delta int64, count int64, cols variable.DeltaCols)
}

The MutateContext also provides methods to get them:

type MutateContext interface {
	// ...
	// GetBinlogSupport returns a `BinlogSupport` if the context supports it.
	// If the context does not support binlog, the second return value will be false.
	GetBinlogSupport() (BinlogSupport, bool)
	// GetStatisticsSupport returns a `StatisticsSupport` if the context supports it.
	// If the context does not support statistics update, the second return value will be false.
	GetStatisticsSupport() (StatisticsSupport, bool)
	// ...
}

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 23, 2024
Copy link

tiprow bot commented Jul 23, 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.

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

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

Project coverage is 56.6394%. Comparing base (f774ef6) to head (61b8b79).
Report is 12 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54832         +/-   ##
=================================================
- Coverage   74.7207%   56.6394%   -18.0813%     
=================================================
  Files          1557       1674        +117     
  Lines        363500     613272     +249772     
=================================================
+ Hits         271610     347354      +75744     
- Misses        72240     242382     +170142     
- Partials      19650      23536       +3886     
Flag Coverage Δ
integration 37.2555% <68.4210%> (?)
unit 71.7320% <89.4736%> (-1.9131%) ⬇️

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.0878% <ø> (+4.4001%) ⬆️

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Jul 23, 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 Jul 23, 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.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

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

ti-chi-bot bot commented Jul 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Jul 24, 2024
Copy link

ti-chi-bot bot commented Jul 24, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-24 04:15:31.767271769 +0000 UTC m=+1018553.758213234: ☑️ agreed by YangKeao.
  • 2024-07-24 05:30:33.223515954 +0000 UTC m=+1023055.214457429: ☑️ agreed by tangenta.

@ti-chi-bot ti-chi-bot bot merged commit d67421d into pingcap:master Jul 24, 2024
22 of 23 checks passed
@lcwangchao lcwangchao deleted the statistics_support branch July 24, 2024 06:10
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/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.

3 participants