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

Query is stuck after disabling some optimization rules #55344

Closed
Nickelth opened this issue Aug 9, 2024 · 16 comments · Fixed by #55418
Closed

Query is stuck after disabling some optimization rules #55344

Nickelth opened this issue Aug 9, 2024 · 16 comments · Fixed by #55418
Assignees

Comments

@Nickelth
Copy link

Nickelth commented Aug 9, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"),("column_prune");
ADMIN reload opt_rule_blacklist; 
CREATE DATABASE database1;
USE database1;
CREATE TABLE t0(c0 BOOL);
SELECT t0.c0 FROM t0 WHERE 0 ORDER BY -646041453 ASC;

2. What did you expect to see? (Required)

Query executed successfully.

3. What did you see instead (Required)

Query was stuck.

4. What is your TiDB version? (Required)

Release Version: v8.3.0-alpha-50-gb59f5ecb47-dirty
Edition: Community
Git Commit Hash: b59f5ecb472d831f867b079e0a409caef9f4a290
Git Branch: master
UTC Build Time: 2024-07-31 18:41:32
GoVersion: go1.22.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@jebter
Copy link

jebter commented Aug 13, 2024

8.2.0 can reproduce the issue.
8.1.0 returns an error:1105, 'interface conversion: expression.Expression is *expression.Constant, not *expression.Column'

@hawkingrei
Copy link
Member

Since disabling certain optimization rules is not the default user behavior and we do not recommend doing so directly, this should be downgraded to moderate.

@hawkingrei
Copy link
Member

hawkingrei commented Aug 13, 2024

before:

+-------------+---------+------+---------------+---------------+
| id          | estRows | task | access object | operator info |
+-------------+---------+------+---------------+---------------+
| TableDual_9 | 0.00    | root |               | rows:0        |
+-------------+---------+------+---------------+---------------+

after:

+-----------------+---------+------+---------------+-----------------+
| id              | estRows | task | access object | operator info   |
+-----------------+---------+------+---------------+-----------------+
| Sort_6          | 0.00    | root |               | -646041453      |
| └─Projection_7  | 0.00    | root |               | database1.t0.c0 |
|   └─TableDual_8 | 0.00    | root |               | rows:0          |
+-----------------+---------+------+---------------+-----------------+

@hawkingrei
Copy link
Member

It is blocked in the executor/sortexec.(*SortExec).Close.

goroutine 365416 [chan receive, 9 minutes]:
github.com/pingcap/tidb/pkg/executor/sortexec.(*SortExec).Close(0x140129c2000)
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-bpw9b-build-binaries/source/tidb/pkg/executor/sortexec/sort.go:118 +0x240
github.com/pingcap/tidb/pkg/executor/internal/exec.Close({0x10582a920?, 0x140129c2000?})
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-bpw9b-build-binaries/source/tidb/pkg/executor/internal/exec/executor.go:467 +0x60
github.com/pingcap/tidb/pkg/executor.(*recordSet).Finish.func1()
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-bpw9b-build-binaries/source/tidb/pkg/executor/adapter.go:200 +0x3c
sync.(*Once).doSlow(0x14001f465e8?, 0x14001f466c8?)
	/usr/local/go1.21/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
	/usr/local/go1.21/src/sync/once.go:65
github.com/pingcap/tidb/pkg/executor.(*recordSet).Finish(0x14004ca2460)

@xzhangxian1008
Copy link
Contributor

xzhangxian1008 commented Aug 13, 2024

INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"); not causes the block.

INSERT INTO mysql.opt_rule_blacklist VALUES ("column_prune"); causes the block

@hawkingrei
Copy link
Member

INSERT INTO mysql.opt_rule_blacklist VALUES ("column_prune");

INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down");

+-------------+---------+------+---------------+---------------+
| id          | estRows | task | access object | operator info |
+-------------+---------+------+---------------+---------------+
| TableDual_9 | 0.00    | root |               | rows:0        |
+-------------+---------+------+---------------+---------------+

INSERT INTO mysql.opt_rule_blacklist VALUES ("column_prune");

+-----------------+---------+------+---------------+-----------------+
| id              | estRows | task | access object | operator info   |
+-----------------+---------+------+---------------+-----------------+
| Sort_6          | 0.00    | root |               | -646041453      |
| └─Projection_7  | 0.00    | root |               | database1.t0.c0 |
|   └─TableDual_8 | 0.00    | root |               | rows:0          |
+-----------------+---------+------+---------------+-----------------+

@hawkingrei
Copy link
Member

Sort with TableDual will lead to block.

@xzhangxian1008
Copy link
Contributor

panic makes chunkChunk can't be closed
image

@xzhangxian1008
Copy link
Contributor

/assign

@xzhangxian1008
Copy link
Contributor

/remove-sig planner

@ti-chi-bot ti-chi-bot bot removed the sig/planner SIG: Planner label Aug 14, 2024
@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-5.4

@ti-chi-bot ti-chi-bot bot removed the may-affects-5.4 This bug maybe affects 5.4.x versions. label Aug 14, 2024
@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-6.1

@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-6.5

@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-7.1

@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-7.5

@xzhangxian1008
Copy link
Contributor

/remove-label may-affects-8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants