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: support compress for lightning, add compress unit and integration tests #39153

Merged
merged 21 commits into from
Nov 28, 2022

Conversation

lichunzhu
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #38514

Problem Summary:

What is changed and how it works?

  • Support file reader for schema files.
  • Add missing usage for sample functions.
  • Add more unit tests and integration tests for compress lightning.

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

lightning support importing compressed sql/csv files 

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 15, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • buchuitoudegou
  • dsdashun

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 15, 2022
@lichunzhu
Copy link
Contributor Author

/run-integration-br-test

@@ -34,6 +34,8 @@ const (
tableRegionSizeWarningThreshold int64 = 1024 * 1024 * 1024
// the increment ratio of large CSV file size threshold by `region-split-size`
largeCSVLowerThresholdRation = 10
// TableFileSizeINF for compressed size, for lightning 10TB is a relatively big value and will strongly affect efficiency
TableFileSizeINF = 10 * 1024 * tableRegionSizeWarningThreshold
Copy link
Contributor

Choose a reason for hiding this comment

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

What does INF mean? infinite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, INF means infinite. It's used to make sure compressed files can be read until the EOF error.

Copy link
Contributor

Choose a reason for hiding this comment

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

set fileSize to INF to make sure compressed files can be read until EOF. Because we can't get the exact size of the compressed files.

I would expect to put its usage in the comment (as well as why this works, maybe)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 46ddf53

@@ -324,6 +324,9 @@ func (p regexRouterParser) Parse(r *config.FileRouteRule, logger log.Logger) (*R
if err != nil {
return err
}
if result.Type == SourceTypeParquet && compression != CompressionNone {
return errors.Errorf("can't support whole compressed parquet file, should compress parquet files by choosing correct parquet compress writer, path: %s", r.Path)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this workaround mean here? I remember we support compressed parquet files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We support compressed binary data in parquet files, but we don't support compressed parquet files like parquet.gz.

if err != nil {
break
}
reader, err = storage.WithCompression(p.srcStorage, compressType).Open(ctx, sampleFile.Path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate with reader.go too. Maybe we should encapsulate this with a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 4c7eaf9

@buchuitoudegou
Copy link
Contributor

/component lightning

@ti-chi-bot ti-chi-bot added the component/lightning This issue is related to Lightning of TiDB. label Nov 18, 2022
@lichunzhu
Copy link
Contributor Author

@buchuitoudegou @dsdashun PTAL

Copy link
Contributor

@buchuitoudegou buchuitoudegou 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

// set fileSize to INF to make sure compressed files can be read until EOF. Because we can't get the exact size of the compressed files.
// TODO: update progress bar calculation for compressed files.
if fi.FileMeta.Compression != CompressionNone {
rowIDMax = fileSize * 100 / divisor
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume we should do some tests on it. It seems this estimate can easily allocate too many row ids and make lightning fail to insert rows that need auto id even when the number of rows is far smaller than the type limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leave a fixme in 46ddf53
I will do some tests and maybe fix this problem in the next PR.

@@ -34,6 +34,8 @@ const (
tableRegionSizeWarningThreshold int64 = 1024 * 1024 * 1024
// the increment ratio of large CSV file size threshold by `region-split-size`
largeCSVLowerThresholdRation = 10
// TableFileSizeINF for compressed size, for lightning 10TB is a relatively big value and will strongly affect efficiency
TableFileSizeINF = 10 * 1024 * tableRegionSizeWarningThreshold
Copy link
Contributor

Choose a reason for hiding this comment

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

set fileSize to INF to make sure compressed files can be read until EOF. Because we can't get the exact size of the compressed files.

I would expect to put its usage in the comment (as well as why this works, maybe)

Copy link
Contributor

@buchuitoudegou buchuitoudegou 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 added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 23, 2022
Copy link
Contributor

@dsdashun dsdashun 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

},
}

if tableRegion.Size() > tableRegionSizeWarningThreshold {
if fi.FileMeta.Compression == CompressionNone && tableRegion.Size() > tableRegionSizeWarningThreshold {
Copy link
Contributor

Choose a reason for hiding this comment

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

If a compressed file's size exceeds the threshold, the actual size is even bigger. So the threshold check is suitable for both compressed and uncompressed file ? Otherwise, the compressed file won't receive this warning message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in a3ce953

Copy link
Contributor

@dsdashun dsdashun 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 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 28, 2022
@lichunzhu
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: a91ad73

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 28, 2022
@ti-chi-bot ti-chi-bot merged commit 5b9d96b into pingcap:master Nov 28, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Nov 28, 2022

TiDB MergeCI notify

🔴 Bad News! New failing [1] after this pr merged.
These new failed integration tests seem to be caused by the current PR, please try to fix these new failed integration tests, thanks!

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test 🟥 failed 1, success 16, total 17 18 min New failing
idc-jenkins-ci/integration-cdc-test 🟢 all 40 tests passed 20 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 9 min 53 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 7 min 37 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 6 min 56 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 6 min 44 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 44 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 5 min 5 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 56 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@lichunzhu lichunzhu deleted the lightningCompress branch December 2, 2022 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/lightning This issue is related to Lightning of TiDB. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants