这是一个朋友问我的,简单记录一下
一、问题
我用的5.7的Mysql undo清理参数已经打开了。为什么undo tablespace没有清理。
![webp](https://upload-images.jianshu.io/upload_images/7398834-a7560794e78ab176.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/815/format/webp)
image.png
二、分析
这种问题应该是有大查询的存在,朋友干掉了大查询后,undo 依然没有清理。
------------ TRANSACTIONS ------------ Trx id counter 33083158036 Purge done for trx's n:o < 31961212290 undo n:o < 0 state: running History list length 560689581 作者微信:**gp_22389860**
我们可以大约理解为560689581个事物的UNDO没有释放。
我们知道undo的分配是循环分配的,清理操作应该等到释放操作完成之后 可以大概从从函数trx_purge_truncate_history看到(我只是初略的看了一眼),只有当所有的undo header,rollback header。之后才能清理整个表空间。
我叫朋友查了一下当前purge线程的压力如下:
![webp](https://upload-images.jianshu.io/upload_images/7398834-2726318a513bf5e1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
image.png
![webp](https://upload-images.jianshu.io/upload_images/7398834-ac01e21a8c8dae9a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
image.png
![webp](https://upload-images.jianshu.io/upload_images/7398834-36fafaf7abdb2a8c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
image.png
虽然没有做pstack,可以猜测purge线程正在清理这些undo记录。等到清理完成后应该可以释放undo tablespace的。然后又看了一下show engine中关于undo的信息如下:
![webp](https://upload-images.jianshu.io/upload_images/7398834-39a9e3935335d47f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
image.png
明显已经开始减少了。再等等吧。
作者微信: gp_22389860
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2640462/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7728585/viewspace-2640462/