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

lightning: allow configure the desired size and number of rows of each INSERT statement for logical mode #46997

Merged
merged 8 commits into from
Feb 18, 2024

Conversation

kennytm
Copy link
Contributor

@kennytm kennytm commented Sep 14, 2023

What problem does this PR solve?

Issue Number: close #46607

Problem Summary:

What is changed and how it works?

Added a config values tikv-importer.logical-import-batch-{size,rows} which controls how big the INSERT statement would be when using logical mode.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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.

In Lightning logical mode, the length of the INSERT statements executed downstream can now be changed from the default 1.0 MiB. Decreasing this allows reducing performance impact caused by large transaction.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 14, 2023
@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #46997 (20a8e9f) into master (f257590) will decrease coverage by 10.3131%.
Report is 236 commits behind head on master.
The diff coverage is 65.3846%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #46997         +/-   ##
=================================================
- Coverage   70.0546%   59.7416%   -10.3131%     
=================================================
  Files          1444       1580        +136     
  Lines        419989     626600     +206611     
=================================================
+ Hits         294222     374341      +80119     
- Misses       105461     229461     +124000     
- Partials      20306      22798       +2492     
Flag Coverage Δ
integration 42.1792% <61.5384%> (?)
unit 73.7852% <57.6923%> (+3.7305%) ⬆️

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

Components Coverage Δ
dumpling 54.0269% <ø> (ø)
parser ∅ <ø> (∅)
br 63.6323% <65.3846%> (+13.9660%) ⬆️

@kennytm
Copy link
Contributor Author

kennytm commented Sep 15, 2023

/retest

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 15, 2023
@D3Hunter
Copy link
Contributor

/hold

new config require discuss with PM

@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 Sep 15, 2023
@D3Hunter
Copy link
Contributor

@Frank945946

@D3Hunter
Copy link
Contributor

D3Hunter commented Sep 19, 2023

@Frank945946 create an FD? requires doc update

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 5, 2024
@ti-chi-bot ti-chi-bot bot removed the approved label Jan 8, 2024
@lance6716
Copy link
Contributor

ping @Frank945946

@Frank945946
Copy link

I will create a FD for v8.0 later

@kennytm
Copy link
Contributor Author

kennytm commented Jan 8, 2024

Just for reference, the size limit is actually effectively capped to 96 KiB

var (
maxKVQueueSize = 32 // Cache at most this number of rows before blocking the encode loop
minDeliverBytes uint64 = 96 * units.KiB // 96 KB (data + index). batch at least this amount of bytes to reduce number of messages
)

but sometimes even a 96 KiB query is too large as disruption on production environment. Also I don't think minDeliverBytes needs to be configured since changing it doesn't have much effect for local backend (physical mode).

removed SplitIntoChunks() from the Rows interface and also MaxChunkSize()
from the Backend interface since the split logic is no longer shared.

reduced default logical-import-batch-size from 1M to 96K to match reality.
@kennytm kennytm changed the title lightning: allow configure the SQL-statement-length for logical mode lightning: allow configure the desired size and number of rows of each INSERT statement for logical mode Jan 11, 2024
@kennytm
Copy link
Contributor Author

kennytm commented Jan 11, 2024

/ok-to-test
/test check-dev2

Copy link

tiprow bot commented Jan 11, 2024

@kennytm: 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/test-infra repository.

@lance6716
Copy link
Contributor

/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 Jan 12, 2024
@D3Hunter
Copy link
Contributor

/test pull-lightning-integration-test

Copy link

tiprow bot commented Jan 12, 2024

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

In response to this:

/test pull-lightning-integration-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/test-infra repository.

@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2024
@D3Hunter
Copy link
Contributor

/test pull-lightning-integration-test

Copy link

tiprow bot commented Jan 15, 2024

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

In response to this:

/test pull-lightning-integration-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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 15, 2024
Copy link

ti-chi-bot bot commented Jan 15, 2024

[LGTM Timeline notifier]

Timeline:

  • 2023-09-15 07:22:00.846323772 +0000 UTC m=+242886.813911807: ☑️ agreed by lance6716.
  • 2024-01-15 02:26:23.217130629 +0000 UTC m=+150024.781428320: ☑️ agreed by D3Hunter.

@D3Hunter
Copy link
Contributor

/retest

Copy link

tiprow bot commented Feb 18, 2024

@D3Hunter: 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/test-infra repository.

@Leavrth
Copy link
Contributor

Leavrth commented Feb 18, 2024

/approve

Copy link
Contributor

@BornChanger BornChanger left a comment

Choose a reason for hiding this comment

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

It's a lightning only change.

Copy link

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

LGTM for the config

Copy link

ti-chi-bot bot commented Feb 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BornChanger, D3Hunter, lance6716, Leavrth, yudongusa

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 the approved label Feb 18, 2024
@ti-chi-bot ti-chi-bot bot merged commit 2d57455 into pingcap:master Feb 18, 2024
33 checks passed
@kennytm kennytm deleted the lightning-sql-statement-length branch February 18, 2024 06:49
@lance6716
Copy link
Contributor

/cherry-pick release-7.5

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 10, 2024
@ti-chi-bot
Copy link
Member

@lance6716: new pull request created to branch release-7.5: #53159.

In response to this:

/cherry-pick release-7.5

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 ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Control the max number of row and bytes lighting sends to tidb
8 participants