From 071ae303bd7ad6ce71f05a25695cd0e9fcef112c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 27 Apr 2016 11:07:43 +0300 Subject: [PATCH] MDEV-9121: innodb_force_recovery = 6 cannot recover ANY DATA when change buffer not empty Fix: Allow not empty change buffer when innodb_force_recovery >= 5 and output only a warning to error log. Note: Before using force recovery you should always take backup of your database. --- storage/innobase/dict/dict0boot.cc | 20 +++++++++++++++----- storage/xtradb/dict/dict0boot.cc | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 573357b54eee5..0dff05567d7c9 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -458,12 +458,22 @@ dict_boot(void) if (err == DB_SUCCESS) { if (srv_read_only_mode && !ibuf_is_empty()) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Change buffer must be empty when --innodb-read-only " - "is set!"); + if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Change buffer must be empty when --innodb-read-only " + "is set! " + "You can try to recover the database with innodb_force_recovery=5"); + + err = DB_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_WARN, + "Change buffer not empty when --innodb-read-only " + "is set! but srv_force_recovery = %d, ignoring.", + srv_force_recovery); + } + } - err = DB_ERROR; - } else { + if (err == DB_SUCCESS) { /* Load definitions of other indexes on system tables */ dict_load_sys_table(dict_sys->sys_tables); diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc index 0a21264e23d7a..59f210fcab9a8 100644 --- a/storage/xtradb/dict/dict0boot.cc +++ b/storage/xtradb/dict/dict0boot.cc @@ -464,12 +464,22 @@ dict_boot(void) if (err == DB_SUCCESS) { if (srv_read_only_mode && !ibuf_is_empty()) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Change buffer must be empty when --innodb-read-only " - "is set!"); + if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Change buffer must be empty when --innodb-read-only " + "is set!" + "You can try to recover the database with innodb_force_recovery=5"); + + err = DB_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_WARN, + "Change buffer not empty when --innodb-read-only " + "is set! but srv_force_recovery = %d, ignoring.", + srv_force_recovery); + } + } - err = DB_ERROR; - } else { + if (err == DB_SUCCESS) { /* Load definitions of other indexes on system tables */ dict_load_sys_table(dict_sys->sys_tables);