Merge "fix: prepare mariadb after restore"

This commit is contained in:
Zuul 2024-01-19 01:43:15 +00:00 committed by Gerrit Code Review
commit cd2f4c2f73
2 changed files with 25 additions and 1 deletions

View File

@ -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."""

View File

@ -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 <https://storyboard.openstack.org/#!/story/2010999>` __