所以,我正在使用 Wordpress、MySQL (8.0.16)、InnoDB。该wp_options
表通常为 13 MB。问题是,它突然(至少在几天内)变成 27 GB,然后停止增长,因为没有更多可用空间。这 27 GB 被视为数据,而不是索引。
转储和导入表格会为您提供正常大小的表格。条目数约为 4k,自增索引为 200k+。对表进行碎片整理ALTER TABLE wp_options ENGINE = InnoDB;
将磁盘上的表大小更改为正常,但即使在服务器重新启动后,mysql 也认为不同。
+------------+------------+
| Table | Size in MB |
+------------+------------+
| wp_options | 26992.56 |
+------------+------------+
1 row in set (0.00 sec)
MySQL日志不多说:
2019-08-05T17:02:41.939945Z 1110933 [ERROR] [MY-012144] [InnoDB] posix_fallocate(): Failed to preallocate data for file ./XXX/wp_options.ibd, desired size 4194304 bytes. Operating system error number 28. Check that the disk is not full or a disk quota exceeded. Make sure the file system supports this function. Some operating system error numbers are described at http://dev.mysql.com/doc/refman/8.0/en/operating-system-error-codes.html
2019-08-05T17:02:41.941604Z 1110933 [Warning] [MY-012637] [InnoDB] 1048576 bytes should have been written. Only 774144 bytes written. Retrying for the remaining bytes.
2019-08-05T17:02:41.941639Z 1110933 [Warning] [MY-012638] [InnoDB] Retry attempts for writing partial data failed.
2019-08-05T17:02:41.941655Z 1110933 [ERROR] [MY-012639] [InnoDB] Write to file ./XXX/wp_options.ibd failed at offset 28917628928, 1048576 bytes should have been written, only 774144 were written. Operating system error number 28. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded.
2019-08-05T17:02:41.941673Z 1110933 [ERROR] [MY-012640] [InnoDB] Error number 28 means 'No space left on device'
我的猜测是某些东西开始添加选项(可能是与瞬态相关的东西?)并且永远不会停止。
问题是,如何调试它?任何帮助/提示将不胜感激。
每小时进行一次 Cron 碎片整理看起来是一个非常糟糕的解决方案。
升级版:
1 天过去了,可用磁盘空间减少了 7 GB。当前的自动增量索引是 206975(昨天有 27 GB 空闲时是 202517)。所以 4.5K 条目 = 7 GB,我猜?
mysql> SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES WHERE table_schema = 'XXX' AND table_name = 'wp_options';
+------------+------------+
| Table | Size in MB |
+------------+------------+
| wp_options | 7085.52 |
+------------+------------+
1 row in set (0.00 sec)
mysql> select ENGINE, TABLE_NAME,Round( DATA_LENGTH/1024/1024) as data_length , round(INDEX_LENGTH/1024/1024) as index_length, round(DATA_FREE/ 1024/1024) as data_free from information_schema.tables where DATA_FREE > 0 and TABLE_NAME = "wp_options" limit 0, 10;
+--------+------------+-------------+--------------+-----------+
| ENGINE | TABLE_NAME | data_length | index_length | data_free |
+--------+------------+-------------+--------------+-----------+
| InnoDB | wp_options | 7085 | 0 | 5 |
+--------+------------+-------------+--------------+-----------+
我将监控可用空间如何减少的动态,也许这会对问题有更多的了解。
UPD(最终)
我有一种感觉,这很愚蠢,我是对的。里面有一个flush_rewrite_rules();
不圣洁的东西functions.php
。检查一般日志很有帮助。