Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 508|回复: 0

MySQL—异常处理

[复制链接]
  • TA的每日心情
    奋斗
    2024-6-6 10:50
  • 签到天数: 750 天

    [LV.10]以坛为家III

    2034

    主题

    2092

    帖子

    70万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    706216
    发表于 2021-6-29 04:36:39 | 显示全部楼层 |阅读模式

    今天在一台测试服务器发现异常,开发人员发来一条sql语句发现无法执行,一直处于等待过程中,sql语句如下:

      1 delete from live.* where _id = 'xxxxx'

    登录服务器,连接mysql发现登录不上

    查看错误日志,报错如下:

      1 2019-01-07T02:12:40.663747Z 61131 [ERROR] InnoDB: posix_fallocate(): Failed to preallocate data for file /data/mysql/3306/innodb/ibtmp1, desired size 67108864 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/5.7/en/ operating-system-error-codes.html
      2 2019-01-07T02:12:41.120936Z 61131 [Warning] InnoDB: 1048576 bytes should have been written. Only 1032192 bytes written. Retrying for the remaining bytes.
      3 2019-01-07T02:12:41.121006Z 61131 [Warning] InnoDB: Retry attempts for writing partial data failed.
      4 2019-01-07T02:12:41.121023Z 61131 [ERROR] InnoDB: Write to file /data/mysql/3306/innodb/ibtmp1failed at offset 50735349760, 1048576 bytes should have been written, only 1032192 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.
      5 2019-01-07T02:12:41.121056Z 61131 [ERROR] InnoDB: Error number 28 means 'No space left on device'
      6 2019-01-07T02:12:41.121068Z 61131 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
      7 2019-01-07T02:12:41.121078Z 61131 [Warning] InnoDB: Error while writing 67108864 zeroes to /data/mysql/3306/innodb/ibtmp1 starting at offset 50679775232
      8 2019-01-07T02:12:41.121129Z 61131 [ERROR] /usr/local/mysql/bin/mysqld: The table '/data/mysql/3306/tmp/#sql_61f8_5' is full
      9 2019-01-07T02:12:41.137490Z 61133 [ERROR] InnoDB: posix_fallocate(): Failed to preallocate data for file /data/mysql/3306/innodb/ibtmp1, desired size 10502144 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/5.7/en/ operating-system-error-codes.html
     10 2019-01-07T02:12:41.137706Z 61133 [Warning] InnoDB: Retry attempts for writing partial data failed.
     11 2019-01-07T02:12:41.137722Z 61133 [Warning] InnoDB: Error while writing 10502144 zeroes to /data/mysql/3306/innodb/ibtmp1 starting at offset 50736381952
     12 2019-01-07T02:12:41.137761Z 61133 [ERROR] /usr/local/mysql/bin/mysqld: The table '/data/mysql/3306/tmp/#sql_61f8_7' is full
     13 2019-01-07T02:39:40.209105Z 61221 [ERROR] InnoDB: posix_fallocate(): Failed to preallocate data for file /data/mysql/3306/innodb/ibtmp1, desired [root


    其中比较关键的这句:

      1 /usr/local/mysql/bin/mysqld: The table '/data/mysql/3306/tmp/#sql_61f8_5' is full

    检查服务器磁盘使用情况,发现负载较高,

    df -h命令发现磁盘100%使用率,ibtmp1文件占用49G

    故障处理:

    删除了服务器上的一些日志文件,这时mysql可以登录

    运行 show processlist命令

    发现有几条sql处于等待状态

    正是这几个sql导致的tmp文件暴增

    sql语句如下:

    desc (SELECT
    	lam.anchor_id,
    	lam.cus_id,
    	lam.anchor_nick_name,
    	lam.theme,
    	lam.classification,
    	lam.live_status,
    	times,
    	lam.l_group,
    	lam.screencap,
    	lam.l_record,
    	lam.sort,
    	cc.ol_number,
    	lpd.pic_name,
    	lpd.pic_path,
    	lam.appllication_time,
    	lam.start_broadcasting_time,
    	lc.lc_name classificationName
    FROM
    	live.live_anchor_management lam
    	LEFT JOIN live.live_picture_dict lpd ON lam.anchor_id = lpd.reference_id
    	AND lpd.pic_property = 0
    	LEFT JOIN customer cc ON lam.cus_id = cc.cus_id
    	LEFT JOIN live.live_category lc ON lam.classification = lc.lc_id
    WHERE
    	lam.verify_status = 0
    	AND lam.live_status = 1
    	AND lam.sort = 1
    ORDER BY
    	lam.sticky_time DESC
    	LIMIT 9999999999 ) UNION
    	DISTINCT (
    SELECT
    	lam.anchor_id,
    	lam.cus_id,
    	lam.anchor_nick_name,
    	lam.theme,
    	lam.classification,
    	lam.live_status,
    	times,
    	lam.l_group,
    	lam.screencap,
    	lam.l_record,
    	lam.sort,
    	cc.ol_number,
    	lpd.pic_name,
    	lpd.pic_path,
    	lam.appllication_time,
    	lam.start_broadcasting_time,
    	lc.lc_name classificationName
    FROM
    	live.live_anchor_management lam
    	LEFT JOIN live.live_picture_dict lpd ON lam.anchor_id = lpd.reference_id
    	AND lpd.pic_property = 0
    	LEFT JOIN customer cc ON lam.cus_id = cc.cus_id
    	LEFT JOIN live.live_category lc ON lam.classification = lc.lc_id
    WHERE
    	verify_status = 0
    	AND live_status = 1
    	)

    重启数据库服务

    恢复正常

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-6-18 21:09 , Processed in 0.070488 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表