崩溃后 InnoDB 回滚期间关闭 MySQL

Dmi*_*zin 4 mysql innodb rollback transaction-log crash

我再一次疑惑了。

昨晚我们在一些大型查询期间发生了服务器崩溃。早上重新启动后,MySQL 进入恢复模式。我需要关闭 MySQL 服务,它正在等待...我假设未提交事务的后台回滚如日志所示,但它已经在 HOT 服务器上运行了 9 个多小时,而且看不到结束的情况。

当服务重新启动时,可以在后台安全地中断并恢复该进程吗?或者我们必须等待它喘息

任何意见或想法(甚至有关正在发生的事情的信息)都会非常有帮助。提前谢谢您。

我们正在运行 MySQL 5.5。

这是日志输出:

140930  9:04:30  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 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
InnoDB: Last MySQL binlog file position 0 41217466, file name .\mysql-bin.001584
InnoDB: Starting in background the rollback of uncommitted transactions
140930  9:26:14  InnoDB: Rolling back trx with id B214637, 15850890 rows to undo

InnoDB: Progress in percents: 1140930  9:26:14  InnoDB: Waiting for the background threads to start
140930  9:26:15 InnoDB: 1.1.8 started; log sequence number 1661733560991
140930  9:26:15 [Note] Server hostname (bind-address): '(null)'; port: 3306
140930  9:26:16 [Note]   - '(null)' resolves to '0.0.0.0';
140930  9:26:16 [Note] Server socket created on IP: '0.0.0.0'.
140930  9:26:18 [Note] Event Scheduler: Loaded 0 events
140930  9:26:18 [Note] wampmysqld: ready for connections.
Version: '5.5.24-log'  socket: ''  port: 3306  MySQL Community Server (GPL)
140930 12:19:36 [Note] wampmysqld: Normal shutdown

140930 12:19:36 [Note] Event Scheduler: Purging the queue. 0 events
140930 12:19:38 [Warning] wampmysqld: Forcing close of thread 20  user: 'root'

140930 12:19:38 [Warning] wampmysqld: Forcing close of thread 19  user: 'root'

140930 12:19:38 [Warning] wampmysqld: Forcing close of thread 17  user: 'root'

140930 12:19:38  InnoDB: Starting shutdown...
140930 12:20:44  InnoDB: Waiting for 1 active transactions to finish
140930 12:21:47  InnoDB: Waiting for 200 pages to be flushed
140930 12:21:49  InnoDB: Waiting for 1 active transactions to finish
140930 12:22:55  InnoDB: Waiting for 1 active transactions to finish
140930 12:24:01  InnoDB: Waiting for 1 active transactions to finish
140930 12:25:07  InnoDB: Waiting for 1 active transactions to finish
140930 12:26:12  InnoDB: Waiting for 1 active transactions to finish
 ... for 9 hours
Run Code Online (Sandbox Code Playgroud)

jyn*_*nus 5

不可以,回滚不能在后台完成。在再次接受连接之前,必须完成该检查和双重写入检查(这意味着如果您终止它,则必须在重新启动时重新开始)。然而,REDO 过程可以并且是在后台完成的。

你可以做的是(再次)杀死 mysql 并重新启动它,跳过该步骤

/etc/init.d/mysqld start --innodb_force_recovery = 3
Run Code Online (Sandbox Code Playgroud)

然后删除有问题的表并从备份中恢复它,这可能比执行巨大的回滚更快。

对于未来,尽量避免对单个事务进行巨大的更改,以避免回滚,这可能比实际提交的成本高出几倍。如果是管理变更,我可以为您提供一些工具来帮助您做到这一点。如果错误是开发人员造成的,我只能向您推荐该选项--i-am-a-dummy。:-)