数据库重启后的回滚异常,造成这张表删除操作一直拿不到锁,求解决办法!

zhongyangjian 2018-05-08 11:11:28
数据库在宕机时(磁盘满了造成的)有一个大事务(删除操作,删除7000万行数据)在运行,所以当释放磁盘空间后,重启数据库时,有看到数据库在回滚,也重启成功了,可是这张表执行单行delete时却一直报:
[SQL] DELETE FROM gsid_and_ua WHERE id =4000000;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

宕机后数据库重启日志如下:
2018-05-07 13:56:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-07 13:56:46 26864 [Note] Plugin 'FEDERATED' is disabled.
2018-05-07 13:56:46 26864 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-07 13:56:46 26864 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-07 13:56:46 26864 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-07 13:56:46 26864 [Note] InnoDB: Memory barrier is not used
2018-05-07 13:56:46 26864 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-07 13:56:46 26864 [Note] InnoDB: Using Linux native AIO
2018-05-07 13:56:46 26864 [Note] InnoDB: Using CPU crc32 instructions
2018-05-07 13:56:46 26864 [Note] InnoDB: Initializing buffer pool, size = 512.0M
2018-05-07 13:56:46 26864 [Note] InnoDB: Completed initialization of buffer pool
2018-05-07 13:56:46 26864 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-07 13:56:46 26864 [Note] InnoDB: Log scan progressed past the checkpoint lsn 1501772147583
2018-05-07 13:56:46 26864 [Note] InnoDB: Database was not shutdown normally!
2018-05-07 13:56:46 26864 [Note] InnoDB: Starting crash recovery.
2018-05-07 13:56:46 26864 [Note] InnoDB: Reading tablespace information from the .ibd files...
2018-05-07 13:56:46 26864 [Note] InnoDB: Restoring possible half-written data pages
2018-05-07 13:56:46 26864 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1501777390080
InnoDB: Doing recovery: scanned up to log sequence number 1501782632960
InnoDB: Doing recovery: scanned up to log sequence number 1501783011554
InnoDB: 2 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 77912583 row operations to undo
InnoDB: Trx id counter is 2524048896
2018-05-07 14:00:09 26864 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
2018-05-07 14:03:31 26864 [Note] InnoDB: 128 rollback segment(s) are active.
InnoDB: Starting in background the rollback of uncommitted transactions
2018-05-07 14:03:31 26864 [Note] InnoDB: Waiting for purge to start
2018-05-07 14:03:31 7f2662db6700 InnoDB: Rolling back trx with id 2524047944, 350 rows to undo
2018-05-07 14:03:31 26864 [Note] InnoDB: Rollback of trx with id 2524047944 completed
2018-05-07 14:03:31 7f2662db6700 InnoDB: Rolling back trx with id 2523159364, 77912233 rows to undo

InnoDB: Progress in percents: 12018-05-07 14:03:31 26864 [Note] InnoDB: 5.6.22 started; log sequence number 1501783011554
2018-05-07 14:03:31 26864 [Note] Server hostname (bind-address): '*'; port: 3306
2018-05-07 14:03:31 26864 [Note] IPv6 is available.
2018-05-07 14:03:31 26864 [Note] - '::' resolves to '::';
2018-05-07 14:03:31 26864 [Note] Server socket created on IP: '::'.
2018-05-07 14:03:32 26864 [Note] Event Scheduler: Loaded 0 events
2018-05-07 14:03:32 26864 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.22' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
...全文
905 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rucypli 2018-05-10
  • 打赏
  • 举报
回复
TRX_WEIGHT The weight of a transaction, reflecting (but not necessarily the exact count of) the number of rows altered and the number of rows locked by the transaction.
zhongyangjian 2018-05-08
  • 打赏
  • 举报
回复
在查询事务表中看到如了回滚操作:
select * from information_schema.innodb_trx;

在我drop table 目标表之后,上面的事务表中字段trx_weight就从7000万慢慢降下来了,有人知道原因么?

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧