fix: prepare mariadb after restore
This PR perform mariabackup prepare in post_restore. Story: 2010999 Task: 49342 Change-Id: Ided7a807575c676fd094c78103201e8dee575d59
This commit is contained in:
parent
f8150f82a3
commit
a8d9ee2291
@ -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."""
|
||||
|
@ -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>` __
|
Loading…
x
Reference in New Issue
Block a user