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

executor: the cached prepared plan is used incorrectly for point get #24741

Closed
cfzjywxk opened this issue May 19, 2021 · 1 comment · Fixed by #24749
Closed

executor: the cached prepared plan is used incorrectly for point get #24741

cfzjywxk opened this issue May 19, 2021 · 1 comment · Fixed by #24749
Assignees
Labels
severity/critical sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@cfzjywxk
Copy link
Contributor

cfzjywxk commented May 19, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

prepare stmt1 using a point get plan
execute some autocommit point get with the prepared stmt1, now the prepared point get plan is cached
start transation
execute the same point get with prepared stmt1

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

The result is returned.

3. What did you see instead (Required)

TiDB reports panic error in v4.0

err="runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/tidb/executor.(*recordSet).Next.func1\n\t/home/rwork/go/src/github.com/pingcap/tidb/executor/adapter.go:124\nruntime.gopanic\n\t/home/rwork/go/go/src/runtime/panic.go:679\nruntime.panicmem\n\t/home/rwork/go/go/src/runtime/panic.go:199\nruntime.sigpanic\n\t/home/rwork/go/go/src/runtime/signal_unix.go:394\ngithub.com/pingcap/tidb/session.(*TxnState).GetSnapshot\n\t:1\ngithub.com/pingcap/tidb/executor.(*PointGetExecutor).Next\n\t/home/rwork/go/src/github.com/pingcap/tidb/executor/point_get.go:151\ngithub.com/pingcap/tidb/executor.Next\n\t/home/rwork/go/src/github.com/pingcap/tidb/executor/executor.go:253\ngithub.com/pingcap/tidb/executor.(*recordSet).Next\n\t/home/rwork/go/src/github.com/pingcap/tidb/executor/adapter.go:128\ngithub.com/pingcap/tidb/server.

4. What is your TiDB version? (Required)

v4.0.8 v4.0.12.
v5.0.1 has the same problem, though it dose not panic, the execution logic is incorrect.

The error is caused that the in transaction point get execute with prepared statement params, the execution should not use the cached plan, the logic check is incomplete, the check should be used.

@ti-srebot
Copy link
Contributor

ti-srebot commented May 19, 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)

The error is caused that the in transaction point get execute with prepared statement params, the execution should not use the cached plan

2. Symptom (optional)

  • panic in release 4.0(v4.0.0 - v4.0.12)
  • maybe incorrect results read after in transaction write(5.0.0, 5.0.1)

3. All Trigger Conditions (optional)

  • prepare stmt1 using a point get plan
  • execute some autocommit point get with the prepared stmt1, now the prepared point get plan is cached
  • start transation
  • execute the same point get with prepared stmt1

4. Workaround (optional)

Don't use the same prepared obects inside a transaction which is created outside.

5. Affected versions

v4.0.0 - v4.0.12
v5.0.0 - v5.0.1

6. Fixed versions

exepected:

  • v4.0.13
  • v5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants