diff --git a/backup/drivers/mariabackup.py b/backup/drivers/mariabackup.py index 17c2d106b6..f5eadb19c8 100644 --- a/backup/drivers/mariabackup.py +++ b/backup/drivers/mariabackup.py @@ -11,7 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import re +from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging @@ -24,7 +26,7 @@ CONF = cfg.CONF class MariaBackup(mysql_base.MySQLBaseRunner): """Implementation of Backup and Restore using mariabackup.""" restore_cmd = ('mbstream -x -C %(restore_location)s') - prepare_cmd = '' + prepare_cmd = 'mariabackup --prepare --target--dir=%(restore_location)s' def __init__(self, *args, **kwargs): super(MariaBackup, self).__init__(*args, **kwargs) @@ -46,6 +48,21 @@ class MariaBackup(mysql_base.MySQLBaseRunner): return True + def post_restore(self): + """Prepare after data restore.""" + LOG.info("Running prepare command: %s.", self.prepare_command) + stdout, stderr = processutils.execute(*self.prepare_command.split()) + LOG.info("The command: %s : stdout: %s, stderr: %s", + self.prepare_command, stdout, stderr) + LOG.info("Checking prepare log") + if not stderr: + msg = "Empty prepare log file" + raise Exception(msg) + last_line = stderr.splitlines()[-1].strip() + if not re.search('completed OK!', last_line): + msg = "Prepare did not complete successfully" + raise Exception(msg) + class MariaBackupIncremental(MariaBackup): """Incremental backup and restore using mariabackup.""" diff --git a/releasenotes/notes/fix-prepare-mariadb-after-restore-472112bbcdcecdb9.yaml b/releasenotes/notes/fix-prepare-mariadb-after-restore-472112bbcdcecdb9.yaml new file mode 100644 index 0000000000..b7e4baba6b --- /dev/null +++ b/releasenotes/notes/fix-prepare-mariadb-after-restore-472112bbcdcecdb9.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fix MariaDB failed to start after restoring from an unprepared backup file. + This bug will appear if the backup file is created while MariaDB is processing + too many update requests. See the following for more details: + `Story 2010999 ` __