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

Join partition table with normal table will cause error: invalid memory address or nil pointer dereference #26250

Closed
lcwangchao opened this issue Jul 14, 2021 · 6 comments · Fixed by #26373
Assignees
Labels
component/executor severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@lcwangchao
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table tp (id int primary key) partition by range (id) (partition p0 values less than (100));
create table tn (id int primary key);
insert into tp values(1),(2);
insert into tn values(1),(2);

select * from tp,tn where tp.id=tn.id and tn.id=1 for update;

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

No error

3. What did you see instead (Required)

mysql> select * from tp,tn where tp.id=tn.id and tn.id=1 for update;
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference

4. What is your TiDB version? (Required)

master

@lcwangchao lcwangchao added the type/bug The issue is confirmed as a bug. label Jul 14, 2021
@lcwangchao lcwangchao changed the title Normal table join partition table will cause error: invalid memory address or nil pointer dereference Join partition table with normal table will cause error: invalid memory address or nil pointer dereference Jul 14, 2021
@XuHuaiyu
Copy link
Contributor

[2021/07/15 10:42:05.376 +08:00] [ERROR] [misc.go:89] ["panic in the recoverable goroutine"] [r="\"invalid memory address or nil pointer dereference\""] ["stack trace"="github.com/pingcap/tidb/util.WithRecovery.func1\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/misc.go:91\nruntime.gopanic\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:965\nruntime.panicmem\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:212\nruntime.sigpanic\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/signal_unix.go:734\ngithub.com/pingcap/parser/model.(*ColumnInfo).GetOriginDefaultValue\n\t/Users/xuhuaiyu/Development/GOPATH/pkg/mod/github.com/pingcap/parser@v0.0.0-20210707071004-31c87e37af5c/model/model.go:158\ngithub.com/pingcap/tidb/table.GetColOriginDefaultValue\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/table/column.go:484\ngithub.com/pingcap/tidb/executor.NewRowDecoder.func2\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/builder.go:4167\ngithub.com/pingcap/tidb/util/rowcodec.(*ChunkDecoder).DecodeToChunk\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/rowcodec/decoder.go:240\ngithub.com/pingcap/tidb/executor.DecodeRowValToChunk\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/point_get.go:517\ngithub.com/pingcap/tidb/executor.(*PointGetExecutor).Next\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/point_get.go:301\ngithub.com/pingcap/tidb/executor.Next\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/executor.go:286\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchBuildSideRows\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/join.go:268\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchAndBuildHashTable.func2\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/join.go:702\ngithub.com/pingcap/tidb/util.WithRecovery\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/misc.go:94"]
[2021/07/15 10:42:05.378 +08:00] [INFO] [conn.go:995] ["command dispatched failed"] [conn=3] [connInfo="id:3, addr:127.0.0.1:54951 status:10, collation:utf8_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="select * from tp,tn where tp.id=tn.id and tn.id=1 for update"] [txn_mode=OPTIMISTIC] [err="runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchAndBuildHashTable.func3\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/join.go:706\ngithub.com/pingcap/tidb/util.WithRecovery.func1\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/misc.go:86\nruntime.gopanic\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:965\nruntime.panicmem\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:212\nruntime.sigpanic\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/signal_unix.go:734\ngithub.com/pingcap/parser/model.(*ColumnInfo).GetOriginDefaultValue\n\t/Users/xuhuaiyu/Development/GOPATH/pkg/mod/github.com/pingcap/parser@v0.0.0-20210707071004-31c87e37af5c/model/model.go:158\ngithub.com/pingcap/tidb/table.GetColOriginDefaultValue\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/table/column.go:484\ngithub.com/pingcap/tidb/executor.NewRowDecoder.func2\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/builder.go:4167\ngithub.com/pingcap/tidb/util/rowcodec.(*ChunkDecoder).DecodeToChunk\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/rowcodec/decoder.go:240\ngithub.com/pingcap/tidb/executor.DecodeRowValToChunk\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/point_get.go:517\ngithub.com/pingcap/tidb/executor.(*PointGetExecutor).Next\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/point_get.go:301\ngithub.com/pingcap/tidb/executor.Next\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/executor.go:286\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchBuildSideRows\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/join.go:268\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchAndBuildHashTable.func2\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/join.go:702\ngithub.com/pingcap/tidb/util.WithRecovery\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/misc.go:94\nruntime.goexit\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/asm_amd64.s:1371"]

@qw4990
Copy link
Contributor

qw4990 commented Jul 15, 2021

caused by #21148

@ti-srebot
Copy link
Contributor

ti-srebot commented Jul 20, 2021

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

When handling select for update and adding extra partition column, do not consider there might be non-partition table.
Lack of testing to cover that case.

2. Symptom (optional)

invalid memory address or nil pointer dereference

3. All Trigger Conditions (optional)

select for update, on normal table join partition table

4. Workaround (optional)

N/A

5. Affected versions

[v5.0.0:v5.0.x], [v5.1.0:v5.1.x]

6. Fixed versions

master

@ti-srebot
Copy link
Contributor

( AffectedVersions ) fields are empty.
The values in ( AffectedVersions ) fields are incorrect.

2 similar comments
@ti-srebot
Copy link
Contributor

( AffectedVersions ) fields are empty.
The values in ( AffectedVersions ) fields are incorrect.

@ti-srebot
Copy link
Contributor

( AffectedVersions ) fields are empty.
The values in ( AffectedVersions ) fields are incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/executor severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
6 participants