MySQL 引入了undo truncate机制, 允许对独立的undo tablespace进行清理操作.
参数
- innodb_undo_log_truncate
truncate开关, 控制是否开启undo truncate功能
函数trx_purge_mark_undo_for_truncate
/** Iterate over all the UNDO tablespaces and check if any of the UNDO
tablespace qualifies for TRUNCATE (size > threshold).
@param[in,out] undo_trunc undo truncate tracker */
static void trx_purge_mark_undo_for_truncate(undo::Truncate *undo_trunc) {
/* We need at least 2 active UNDO tablespaces so that if one undo
tablespace is being truncated the server will continue to operate.
The minimum is now 2 so assert that we have at least 2. */
ut_a(undo::spaces->size() >= FSP_MIN_UNDO_TABLESPACES);
/* Return immediately if
1. truncate is disabled or
2. an undo tablespace is currently marked for truncate. */
if (!srv_undo_log_truncate || undo_trunc->is_marked()) {
return;
}
- inn