建立表執行出錯
DDL的執行是一個分布式處理過程,出錯可能導緻各個分片表結構不一緻,是以需要進行手動清理,詳細操作步驟如下:
- PolarDB-X會提供基本的錯誤描述資訊,比如文法錯誤等。如果錯誤資訊太長,則會提示您使用
來檢視每個分庫執行失敗的原因。SHOW WARNINGS
- 執行
指令來檢視實體表的拓撲結構。SHOW TOPOLOGY
SHOW TOPOLOGY FROM multi_db_multi_tbl;
+------+-----------------+-----------------------+
| ID | GROUP_NAME | TABLE_NAME |
+------+-----------------+-----------------------+
| 0 | corona_qatest_0 | multi_db_multi_tbl_00 |
| 1 | corona_qatest_0 | multi_db_multi_tbl_01 |
| 2 | corona_qatest_0 | multi_db_multi_tbl_02 |
| 3 | corona_qatest_1 | multi_db_multi_tbl_03 |
| 4 | corona_qatest_1 | multi_db_multi_tbl_04 |
| 5 | corona_qatest_1 | multi_db_multi_tbl_05 |
| 6 | corona_qatest_2 | multi_db_multi_tbl_06 |
| 7 | corona_qatest_2 | multi_db_multi_tbl_07 |
| 8 | corona_qatest_2 | multi_db_multi_tbl_08 |
| 9 | corona_qatest_3 | multi_db_multi_tbl_09 |
| 10 | corona_qatest_3 | multi_db_multi_tbl_10 |
| 11 | corona_qatest_3 | multi_db_multi_tbl_11 |
+------+-----------------+-----------------------+
12 rows in set (0.21 sec)
-
語句來檢視邏輯表是否建立成功。例如下面的例子展示了multi_db_multi_tbl的某個實體分表沒有建立成功時的情況。CHECK TABLE tablename
mysql> check table multi_db_multi_tbl;
+-------------------------------------------------+-------+----------+---------------------------------------------------------------------------+
| TABLE | OP | MSG_TYPE | MSG_TEXT |
+-------------------------------------------------+-------+----------+---------------------------------------------------------------------------+
| andor_mysql_qatest. multi_db_multi_tbl | check | Error | Table 'corona_qatest_0. multi_db_multi_tbl_02' doesn't exist |
+-------------------------------------------------+-------+----------+---------------------------------------------------------------------------+
1 row in set (0.16 sec)
- 使用幂等的方式重新執行建表或删表操作,該操作會建立或删除剩餘的實體表。
CREATE TABLE IF NOT EXISTS table1
(id int, name varchar(30), primary key(id))
dbpartition by hash(id);
DROP TABLE IF EXISTS table1;
建索引失敗或加列失敗
建索引失敗或加列失敗的處理方法跟上面建表失敗的處理類似,詳情請參見
如何正确處理DDL異常。