Skip to content

importinto/lightning: check max row size when parsing csv to avoid OOM#58592

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:masterfrom
D3Hunter:check-csv-rowsize
Dec 31, 2024
Merged

importinto/lightning: check max row size when parsing csv to avoid OOM#58592
ti-chi-bot[bot] merged 3 commits intopingcap:masterfrom
D3Hunter:check-csv-rowsize

Conversation

@D3Hunter
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #58590

Problem Summary:

What changed and how does it work?

Check List

Tests

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

import a file with 20 fields, each field is about 10+M, total row size is about 266M

mysql> import into t from '/playground/lightning/single-file/long-row.csv';
ERROR 1105 (HY000): size of row cannot exceed the max value of txn-entry-size-limit
mysql>
  • 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 27, 2024
@tiprow
Copy link

tiprow bot commented Dec 27, 2024

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 requested a review from lance6716 December 27, 2024 10:02
@D3Hunter D3Hunter changed the title lightning: check max row size when parsing csv lightning: check max row size when parsing csv to avoid OOM Dec 27, 2024
@D3Hunter D3Hunter changed the title lightning: check max row size when parsing csv to avoid OOM importinto/lightning: check max row size when parsing csv to avoid OOM Dec 27, 2024
@codecov
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.3149%. Comparing base (b11cce7) to head (8ecabbd).
Report is 537 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58592        +/-   ##
================================================
+ Coverage   73.5283%   74.3149%   +0.7865%     
================================================
  Files          1680       1710        +30     
  Lines        464577     478215     +13638     
================================================
+ Hits         341596     355385     +13789     
+ Misses       102128     101300       -828     
- Partials      20853      21530       +677     
Flag Coverage Δ
integration 46.1870% <86.6666%> (?)
unit 73.1353% <100.0000%> (+0.5961%) ⬆️

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

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

@D3Hunter
Copy link
Contributor Author

@lance6716

for {
buf = append(buf, parser.buf...)
if len(buf) > LargestEntryLimit {
if parser.checkRowLen && parser.pos-parser.rowStartPos+int64(len(buf)) > int64(LargestEntryLimit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

in all cases, parser.checkRowLen is true when running here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only public API check it, i.e. ReadRow/ReadColumns/ReadUntilTerminator

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 31, 2024
@ti-chi-bot
Copy link

ti-chi-bot bot commented Dec 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, lance6716

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 31, 2024
@ti-chi-bot
Copy link

ti-chi-bot bot commented Dec 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-31 07:36:17.40224324 +0000 UTC m=+422312.758247800: ☑️ agreed by lance6716.
  • 2024-12-31 09:10:33.070245252 +0000 UTC m=+427968.426249817: ☑️ agreed by GMHDBJD.

@ti-chi-bot ti-chi-bot bot merged commit b71ad38 into pingcap:master Dec 31, 2024
@D3Hunter D3Hunter deleted the check-csv-rowsize branch December 31, 2024 11:15
@tangenta tangenta added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Feb 11, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 11, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #59408.
But this PR has conflicts, please resolve them!

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #59630.

@Benjamin2037 Benjamin2037 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Apr 11, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #60500.

@joechenrh
Copy link
Contributor

/cherry-pick release-8.1

@ti-chi-bot
Copy link
Member

@joechenrh: new pull request created to branch release-8.1: #62126.

Details

In response to this:

/cherry-pick release-8.1

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 needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check max row size when parsing csv

7 participants