Mysql資料庫Multi-statement transaction required more than ‘max_binlog_cache_size‘ bytes of storage錯誤處理
阿新 • • 發佈:2021-01-08
技術標籤:Mysql
1、 故障描述
使用mysql批量更新或批量刪除的大事務時可能會出現以下錯誤
Multi-statement transaction required more than ‘max_binlog_cache_size’ bytes of storage; increase this mysqld variable and try again
這是由於更新和刪除的innerDB的大事務會寫入大量binlog,可能會造成binlog cache過小而導致執行失敗。
報錯會導致主從庫同步不成功或者批量更新刪除失敗的現象。
mysql> show variables like 'max_binlog_cache_size'; +-----------------------+-----------+ | Variable_name | Value | +-----------------------+-----------+ | max_binlog_cache_size | 134217728 | +-----------------------+-----------+
檢視該引數設定為134217728B,即128MB
還可以通過show global status like 'bin%';檢視binlog_cache_size的使用情況
Binlog_cache_disk_use表示因為我們binlog_cache_size設計的記憶體不足導致快取二進位制日誌用到了臨時檔案的次數
Binlog_cache_use 表示 用binlog_cache_size快取的次數
當對應的Binlog_cache_disk_use 值比較大的時候 我們可以考慮適當的調高 binlog_cache_size 對應的值
2 、故障處理
處理過程倒是非常簡單,該引數可以動態修改,因此直接調整主庫及從庫的值。因為也確實沒必要還原為預設值,畢竟達不到那麼大,因此,先將其設定為20GB
mysql> set global max_binlog_cache_size=20*1024*1024*1024;
Query OK, 0 rows affected (0.00 sec)
注意:
1) 主庫及從庫均進行調整
2) 動態修改後配置檔案也需要修改,以免重啟後有還原回去了
3)max_binlog_cache_size引數與binlog_cache_size以及Binlog_cache_use等引數有關,因此設定時要根據實際情況調整,千萬不可無腦的跟風設定