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:
@@ -11,7 +11,9 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import re
|
||||||
|
|
||||||
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ CONF = cfg.CONF
|
|||||||
class MariaBackup(mysql_base.MySQLBaseRunner):
|
class MariaBackup(mysql_base.MySQLBaseRunner):
|
||||||
"""Implementation of Backup and Restore using mariabackup."""
|
"""Implementation of Backup and Restore using mariabackup."""
|
||||||
restore_cmd = ('mbstream -x -C %(restore_location)s')
|
restore_cmd = ('mbstream -x -C %(restore_location)s')
|
||||||
prepare_cmd = ''
|
prepare_cmd = 'mariabackup --prepare --target--dir=%(restore_location)s'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MariaBackup, self).__init__(*args, **kwargs)
|
super(MariaBackup, self).__init__(*args, **kwargs)
|
||||||
@@ -46,6 +48,21 @@ class MariaBackup(mysql_base.MySQLBaseRunner):
|
|||||||
|
|
||||||
return True
|
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):
|
class MariaBackupIncremental(MariaBackup):
|
||||||
"""Incremental backup and restore using 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>` __
|
||||||
Reference in New Issue
Block a user