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

wrong behavior for SQL bind when table is dropped #13825

Closed
eurekaka opened this issue Nov 29, 2019 · 0 comments · Fixed by #13875
Closed

wrong behavior for SQL bind when table is dropped #13825

eurekaka opened this issue Nov 29, 2019 · 0 comments · Fixed by #13875
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

eurekaka commented Nov 29, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
mysql> create table t(a int, b int, key(b));
Query OK, 0 rows affected (0.01 sec)

mysql> create global binding for select * from t using select * from t use index(b);
Query OK, 0 rows affected (0.01 sec)

mysql> show global bindings;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| Original_sql    | Bind_sql                     | Default_db | Status | Create_time             | Update_time             | Charset | Collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:23:42.800 | 2019-11-18 18:23:42.800 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
1 row in set (0.00 sec)

mysql> select * from mysql.bind_info;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| original_sql    | bind_sql                     | default_db | status | create_time             | update_time             | charset | collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:23:42.800 | 2019-11-18 18:23:42.800 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
1 row in set (0.00 sec)

mysql> drop table t;
Query OK, 0 rows affected (0.03 sec)

mysql> show global bindings;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| Original_sql    | Bind_sql                     | Default_db | Status | Create_time             | Update_time             | Charset | Collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:31:55.675 | 2019-11-18 18:31:55.675 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
1 row in set (0.00 sec)

mysql> select * from mysql.bind_info;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| original_sql    | bind_sql                     | default_db | status | create_time             | update_time             | charset | collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:31:55.675 | 2019-11-18 18:31:55.675 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
1 row in set (0.00 sec)

mysql> create table t(c1 int, c2 int);
Query OK, 0 rows affected (0.01 sec)

mysql> select * from mysql.bind_info;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| original_sql    | bind_sql                     | default_db | status | create_time             | update_time             | charset | collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:31:55.675 | 2019-11-18 18:31:55.675 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
1 row in set (0.00 sec)

mysql> show global bindings;
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| Original_sql    | Bind_sql                     | Default_db | Status | Create_time             | Update_time             | Charset | Collation       |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
| select * from t | select * from t use index(b) | tmp        | using  | 2019-11-18 18:31:55.675 | 2019-11-18 18:31:55.675 | utf8    | utf8_general_ci |
+-----------------+------------------------------+------------+--------+-------------------------+-------------------------+---------+-----------------+
  1. What did you expect to see?

No endless error in log, and show global bindings and select * from mysql.bind_info should contain no record after a few rounds of ERROR.

  1. What did you see instead?

After drop table t, there are endless errors in log like

[2019/11/18 18:35:22.676 +08:00] [ERROR] [handle.go:157] ["update bindinfo failed"] [error="[schema:1146]Table 'tmp.t' doesn't exist"]

and after re-create the table with another schema, the error log changes to be:

[2019/11/18 18:35:52.675 +08:00] [ERROR] [handle.go:157] ["update bindinfo failed"] [error="[planner:1176]Key 'b' doesn't exist in table 't'"]
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v4.0.0-alpha-1029-gd438c86
Git Commit Hash: d438c860a660f00c755094e1d6c9e61c18715edf
Git Branch: refine_args
UTC Build Time: 2019-11-18 10:01:47
GoVersion: go1.13.1
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants