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

Cancel MPPQuery should take effect in MPPGather's level #7746

Closed
windtalker opened this issue Jul 5, 2023 · 0 comments · Fixed by #7772
Closed

Cancel MPPQuery should take effect in MPPGather's level #7746

windtalker opened this issue Jul 5, 2023 · 0 comments · Fixed by #7772
Assignees
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@windtalker
Copy link
Contributor

Enhancement

Sometimes in TiDB a query will generate multiple standalone "mpp sub-queries", for example:

mysql> explain select * from test a join (select * from test limit 10) b on a.id = b.id;
+------------------------------------+------------+--------------+---------------+----------------------------------------------------+
| id                                 | estRows    | task         | access object | operator info                                      |
+------------------------------------+------------+--------------+---------------+----------------------------------------------------+
| HashJoin_13                        | 3506304.00 | root         |               | inner join, equal:[eq(test.test.id, test.test.id)] |
| ├─Selection_22(Build)              | 8.00       | root         |               | not(isnull(test.test.id))                          |
| │ └─Limit_25                       | 10.00      | root         |               | offset:0, count:10                                 |
| │   └─TableReader_33               | 10.00      | root         |               | MppVersion: 2, data:ExchangeSender_32              |
| │     └─ExchangeSender_32          | 10.00      | mpp[tiflash] |               | ExchangeType: PassThrough                          |
| │       └─Limit_31                 | 10.00      | mpp[tiflash] |               | offset:0, count:10                                 |
| │         └─TableFullScan_30       | 10.00      | mpp[tiflash] | table:test    | keep order:false                                   |
| └─TableReader_21(Probe)            | 524288.00  | root         |               | MppVersion: 2, data:ExchangeSender_20              |
|   └─ExchangeSender_20              | 524288.00  | mpp[tiflash] |               | ExchangeType: PassThrough                          |
|     └─Selection_19                 | 524288.00  | mpp[tiflash] |               | not(isnull(test.test.id))                          |
|       └─TableFullScan_18           | 524288.00  | mpp[tiflash] | table:a       | pushed down filter:empty, keep order:false         |
+------------------------------------+------------+--------------+---------------+----------------------------------------------------+
11 rows in set (0.00 sec)

ExchangeSender_32 and ExchangeSender_20 are actually two standalone mpp sub-queries, and each of the subqueries in TiDB side is handled by a mpp_gather, so this query will generate mpp tasks that belongs two different mpp_gather. From tidb's point of view, different mpp_gather has its own lifecycle, it is possible that TiDB wants to cancel one of the mpp_gather's execution while keep other mpp_gather's execution un-affected. For example, if Limit_25 has enough input, TiDB will cancel the mpp_gather that opens ExchangeSender_32, and of cause, TiDB does not want ExchangeSender_20 to be affected by that cancel(After #7589, it almost 100% sure that ExchangeSender_20 will be affected by that cancel). This means when TiDB send a CancelMPPQuery request, it actually wants to cancel all the mpp tasks that belongs to a specific mpp_gather. After pingcap/tidb#44697, TiDB already set a meaningfull value of gather_id in mpp::TaskMeta, it's time for TiFlash to support MPPGather' level's cancel

@windtalker windtalker added the type/enhancement The issue or PR belongs to an enhancement. label Jul 5, 2023
@windtalker windtalker self-assigned this Jul 5, 2023
ti-chi-bot bot pushed a commit that referenced this issue Jul 11, 2023
ti-chi-bot bot pushed a commit that referenced this issue Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant