wesql / wescale

WeScale is a Modern MySQL proxy that supports read-write-split, read-after-write-consistency, load balancing and OnlineDDL.
https://wesql.io
Apache License 2.0
203 stars 8 forks source link

[Bug Report] vttablet ddl keyspace error #267

Closed gerayking closed 1 year ago

gerayking commented 1 year ago

Overview of the Issue

Currently, the DDL statement cannot select the correct database even after invoking 'use database'; it continues to default to the mysql database.I've noticed that the QueryExecutor doesn't record the dbName passed from vtgate.Should we consider fixing this in vtgate or vttablet?

Reproduction Steps

(base) ➜  ~ mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.30-Vitess Version: 16.0.0 (Git revision  branch '') built on  by @ using go1.20.4 darwin/arm64

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1             |
+----------------+
1 row in set (3.11 sec)

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> alter table t1 add column v3 int;
ERROR 1146 (42S02): target: test.0.primary: vttablet: rpc error: code = NotFound desc = Table 'mysql.t1' doesn't exist (errno 1146) (sqlstate 42S02) (CallerID: userData1): Sql: "alter table t1 add column v3 int", BindVars: {}

Binary Version

No response

Operating System and Environment details

No response

Log Fragments

No response

earayu commented 1 year ago

This problem need to be fixed.

earayu commented 1 year ago

I think keyspace, shard, dbName should be removed in onlineddl.Executor

gerayking commented 1 year ago

I think keyspace, shard, dbName should be removed in onlineddl.Executor

Perhaps retaining the shard is a better option, as removing it might be too costly.