Skip to content

Process streams of partition tables one by one in MultiplexInputStream#8507

Merged
ti-chi-bot[bot] merged 10 commits intopingcap:masterfrom
gengliqi:fix-multiplex
Dec 14, 2023
Merged

Process streams of partition tables one by one in MultiplexInputStream#8507
ti-chi-bot[bot] merged 10 commits intopingcap:masterfrom
gengliqi:fix-multiplex

Conversation

@gengliqi
Copy link
Contributor

@gengliqi gengliqi commented Dec 12, 2023

What problem does this PR solve?

Issue Number: close #8505

Problem Summary:
See #8505.

What is changed and how it works?

In the previous code, many streams of different partition tables may be processed concurrently. This PR simply fixes it by processing streams of partition tables one by one.

Check List

Tests

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

create a table with 36 partitions.
Test SQL select * from employees.

mysql> explain analyze select * from employees;
+-------------------------+--------------+-----------+--------------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+---------+------+
| id                      | estRows      | actRows   | task         | access object   | execution info                                                                                                                                                                                                                                                                                                                                                                                                    | operator info                             | memory  | disk |
+-------------------------+--------------+-----------+--------------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+---------+------+
| TableReader_11          | 436207616.00 | 603979776 | root         | partition:all   | time:13.4s, loops:590554, RU:0.000000, cop_task: {num: 10160, max: 0s, min: 0s, avg: 0s, p95: 0s, copr_cache_hit_ratio: 0.00}                                                                                                                                                                                                                                                                                     | MppVersion: 1, data:ExchangeSender_10     | 7.92 MB | N/A  |
| └─ExchangeSender_10     | 436207616.00 | 603979776 | mpp[tiflash] |                 | tiflash_task:{proc max:12.9s, min:12.6s, avg: 12.7s, p80:12.9s, p95:12.9s, iters:10283, tasks:2, threads:72}                                                                                                                                                                                                                                                                                                      | ExchangeType: PassThrough                 | N/A     | N/A  |
|   └─TableFullScan_9     | 436207616.00 | 603979776 | mpp[tiflash] | table:employees | tiflash_task:{proc max:137.4ms, min:121ms, avg: 129.2ms, p80:137.4ms, p95:137.4ms, iters:10283, tasks:2, threads:72}, tiflash_scan:{dtfile:{total_scanned_packs:94981, total_skipped_packs:15416, total_scanned_rows:774644749, total_skipped_rows:125859659, total_rs_index_load_time: 0ms, total_read_time: 35296ms}, total_create_snapshot_time: 3ms, total_local_region_num: 972, total_remote_region_num: 0} | keep order:false, PartitionTableScan:true | N/A     | N/A  |
+-------------------------+--------------+-----------+--------------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+---------+------+
3 rows in set (13.45 sec)
image

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

Fix potential OOM when scanning many partition tables under stream model.

Signed-off-by: gengliqi <gengliqiii@gmail.com>
@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 12, 2023
@gengliqi
Copy link
Contributor Author

/run-all-tests

@windtalker
Copy link
Contributor

Can you do some manual tests to show the memory usage with/without this pr?

Copy link
Contributor

@SeaRise SeaRise 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 13, 2023
@gengliqi
Copy link
Contributor Author

/run-all-tests

Signed-off-by: gengliqi <gengliqiii@gmail.com>
Signed-off-by: gengliqi <gengliqiii@gmail.com>
Copy link
Contributor

@windtalker windtalker 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
Copy link
Contributor

ti-chi-bot bot commented Dec 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SeaRise, windtalker

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 14, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 14, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-13 05:25:19.953213337 +0000 UTC m=+420210.990440264: ☑️ agreed by SeaRise.
  • 2023-12-14 07:21:30.762528321 +0000 UTC m=+513581.799755248: ☑️ agreed by windtalker.

@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. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 14, 2023
@gengliqi gengliqi added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Dec 14, 2023
@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 Dec 14, 2023
Signed-off-by: gengliqi <gengliqiii@gmail.com>
@gengliqi
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-triage-completed and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/needs-triage-completed labels Dec 14, 2023
@gengliqi
Copy link
Contributor Author

/run-all-tests

@gengliqi
Copy link
Contributor Author

/run-unit-test

@ti-chi-bot ti-chi-bot bot merged commit d344d9a into pingcap:master Dec 14, 2023
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Dec 14, 2023
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: #8521.

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Dec 14, 2023
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-7.1: #8522.

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Dec 14, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. 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.

TiFlash may be OOM when scanning many partition tables under stream model

4 participants