/usr/lib/python2.7/dist-packages/mysql/fabric/recovery.py is in mysql-utilities 1.6.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #
# Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
"""This module is responsible for ensuring that the system is in a
consistent state after a crash.
"""
import logging
import mysql.fabric.executor as _executor
from mysql.fabric.checkpoint import (
Checkpoint,
)
_LOGGER = logging.getLogger(__name__)
def recovery():
"""Recover after a crash any incomplete procedure.
It assumes that the executor is already running and that the recovery
is sequential. In the future, we may consider optimizing this function.
:return: False, if nothing bad happened while recovering. Otherwise,
return True.
"""
Checkpoint.cleanup()
error = False
for checkpoint in Checkpoint.unfinished():
if checkpoint.undo_action:
procedure = _executor.Executor().enqueue_procedure(
False, checkpoint.undo_action,
"Recovering %s." % (checkpoint.undo_action, ),
checkpoint.lockable_objects,
*checkpoint.param_args, **checkpoint.param_kwargs
)
procedure.wait()
if procedure.status[-1]['success'] != _executor.Job.SUCCESS:
_LOGGER.error("Error while recovering %s.",
(checkpoint.do_action, ))
error = True
actions = []
procedure_uuid = None
for checkpoint in Checkpoint.registered():
actions.append({
"job" : checkpoint.job_uuid,
"action" : (checkpoint.do_action,
"Recovering %s." % (checkpoint.do_action, ),
checkpoint.param_args, checkpoint.param_kwargs)}
)
if procedure_uuid is not None and \
procedure_uuid != checkpoint.proc_uuid:
_executor.Executor().reschedule_procedure(
procedure_uuid, actions, checkpoint.lockable_objects
)
procedure_uuid = None
actions = []
procedure_uuid = checkpoint.proc_uuid
if procedure_uuid is not None:
_executor.Executor().reschedule_procedure(
procedure_uuid, actions, checkpoint.lockable_objects
)
return error
|