共計(jì) 2233 個(gè)字符,預(yù)計(jì)需要花費(fèi) 6 分鐘才能閱讀完成。
這篇文章主要介紹“怎么解決 MySQL 中的 ERROR 1799 報(bào)錯(cuò)問題”,在日常操作中,相信很多人在怎么解決 MySQL 中的 ERROR 1799 報(bào)錯(cuò)問題問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么解決 MySQL 中的 ERROR 1799 報(bào)錯(cuò)問題”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學(xué)習(xí)吧!
【問題描述】:
版本:MySQL 5.6.36(以上的版本都可能出現(xiàn))
行為:對某些訪問頻繁的大表做 Online DDL
現(xiàn)象:
ERROR 1799 (HY000): Creating index GEN_CLUST_INDEX required more than innodb_online_alter_log_max_size bytes of modification log. Please try again.
比如:
mysql ALTER TABLE a ENGINE=innodb;
ERROR 1799 (HY000): Creating index GEN_CLUST_INDEX required more than innodb_online_alter_log_max_size bytes of modification log. Please try again.
mysql ALTER TABLE a DROP idx_name;
ERROR 1799 (HY000): Creating index idx required more than innodb_online_alter_log_max_size bytes of modification log. Please try again.
只要是 DDL 相關(guān)的,就可能遇到這樣的問題,比如在 optimize table 時(shí):
mysql OPTIMIZE TABLE a;
+——–+———-+———-+——————————————————————-+
| Table | Op | Msg_type | Msg_text |
+——–+———-+———-+——————————————————————-+
| test.a | optimize | note | Table does not support optimize, doing recreate + analyze instead |
| test.a | optimize | error | Creating index FTS_DOC_ID_INDEX required more than innodb_online_alter_log_max_size bytes of modification log. Please try again. |
| test.a | optimize | status | OK |
+——–+———-+———-+——————————————————————-+
2 rows in set (18.13 sec)
雖然 optimize 對 innodb 表沒什么用,但是仍然會拋出該錯(cuò)誤
那么查看一下手冊,可以得知:
innodb_online_alter_log_max_size 控制在用于在 Online DDL 操作時(shí)的一個(gè)臨時(shí)的日志文件的上限值大小。
該臨時(shí)的日志文件存儲了在 DDL 時(shí)間內(nèi),dml 操作的記錄。這個(gè)臨時(shí)的日志文件依照 innodb_sort_buffer_size 的值做擴(kuò)展。
如果該日志超過了 innodb_online_alter_log_max_size 的最大上限,DDL 操作則會拋出失敗,并且回滾所有未提交的 DML 操作。
反過來說,該值如果設(shè)置更高,則可以允許在做 Online DDL 時(shí),有更多的 DML 操作發(fā)生。
但因此帶來的問題就是,在 DDL 做完之后,需要更多時(shí)間來鎖表和應(yīng)用這些日志。
另外對于某些 DDL 操作,比如
ADD INDEX/COLUMN,則可以通過調(diào)整 innodb_sort_buffer_size 的大小來加快操作速度。
但是實(shí)際上分配的內(nèi)存為 3 倍的 innodb_sort_buffer_size 值。
innodb_online_alter_log_max_size 和 innodb_sort_buffer_size 均為 5.6 Online DDL 的新參數(shù)。
【解決方案】:
知道這個(gè)參數(shù)控制的是什么東西,就好解決了。
臨時(shí)調(diào)大該值,此處改成了 256MB:
mysql SET GLOBAL innodb_online_alter_log_max_size=256*1024*1024;
Query OK, 0 rows affected (0.03 sec)
該值默認(rèn)為 128MB,還是建議在做完 DDL 之后再將其改為默認(rèn)值,也就是 134217728。
到此,關(guān)于“怎么解決 MySQL 中的 ERROR 1799 報(bào)錯(cuò)問題”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!