我正在尝试添加一个大型MySQL表的字段:
mysql> alter table `offer_clicks` add `reconciled_at` datetime, algorithm=inplace, lock=none;
经过几个小时的工作后,该过程失败了:
ERROR 2013 (HY000): Lost connection to MySQL server during query
我每次尝试过几次这个过程有不同的错误,我一直在逐一解决,问题是在上一次错误之后,进程中使用的磁盘空间还没有被恢复:
正如您在上图所示,我首先升级了磁盘的空间,因为我知道添加新的字段进程将消耗大约700GB(我已经在另一个数据库中测试了它),然后我尝试了一些时间每次故障后,磁盘空间都会恢复,但不会在最后一次故障后恢复。
show full processlist
。如何恢复丢失的空间?
有关该表的信息:
mysql> show table status where Name="offer_clicks" \G
*************************** 1. row ***************************
Name: offer_clicks
Engine: InnoDB
Version: 10
Row_format: Dynamic
Rows: 98238612
Avg_row_length: 6102
Data_length: 599495016448
Max_data_length: 0
Index_length: 58622377984
Data_free: 4194304
Auto_increment: 145148580
Create_time: 2017-06-30 10:40:11
Update_time: 2017-12-30 10:28:49
Check_time: NULL
Collation: utf8_unicode_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
重要变量:
mysql> show variables where Variable_name="innodb_file_per_table" \G
*************************** 1. row ***************************
Variable_name: innodb_file_per_table
Value: ON
1 row in set (0.01 sec)
有关临时文件的信息:
mysql> SELECT * FROM INFORMATION_SCHEMA.FILES WHERE TABLESPACE_NAME='innodb_temporary'\G
*************************** 1. row ***************************
FILE_ID: 775
FILE_NAME: /rdsdbdata/db/innodb/ibtmp1
FILE_TYPE: TEMPORARY
TABLESPACE_NAME: innodb_temporary
TABLE_CATALOG:
TABLE_SCHEMA: NULL
TABLE_NAME: NULL
LOGFILE_GROUP_NAME: NULL
LOGFILE_GROUP_NUMBER: NULL
ENGINE: InnoDB
FULLTEXT_KEYS: NULL
DELETED_ROWS: NULL
UPDATE_COUNT: NULL
FREE_EXTENTS: 32
TOTAL_EXTENTS: 76
EXTENT_SIZE: 1048576
INITIAL_SIZE: 12582912
MAXIMUM_SIZE: NULL
AUTOEXTEND_SIZE: 67108864
CREATION_TIME: NULL
LAST_UPDATE_TIME: NULL
LAST_ACCESS_TIME: NULL
RECOVER_TIME: NULL
TRANSACTION_COUNTER: NULL
VERSION: NULL
ROW_FORMAT: NULL
TABLE_ROWS: NULL
AVG_ROW_LENGTH: NULL
DATA_LENGTH: NULL
MAX_DATA_LENGTH: NULL
INDEX_LENGTH: NULL
DATA_FREE: 75497472
CREATE_TIME: NULL
UPDATE_TIME: NULL
CHECK_TIME: NULL
CHECKSUM: NULL
STATUS: NORMAL
EXTRA: NULL
1 row in set (0.00 sec)