You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-5594: Interactive "mcs cluster stop" command for CMAPI. (#3024)
* MCOL-5594: Interactive "mcs cluster stop" command for CMAPI. [add] NodeProcessController class to handle Node operations [add] two endpoints: stop_dmlproc (PUT) and is_process_running (GET) [add] NodeProcessController.put_stop_dmlproc method to separately stop DMLProc on primary Node [add] NodeProcessController.get_process_running method to check if specified process running or not [add] build_url function to helpers.py. It needed to build urls with query_params [add] MCSProcessManager.gracefully_stop_dmlproc method [add] MCSProcessManager.is_service_running method as a top level wrapper to the same method in dispatcher [fix] MCSProcessManager.stop by using new gracefully_stop_dmlproc [add] interactive option and mode to mcs cluster stop command [fix] requirements.txt with typer version to 0.9.0 where supports various of features including "Annotated" [fix] requirements.txt click version (8.1.3 -> 8.1.7) and typing-extensions (4.3.0 -> 4.8.0). This is dependencies for typer package. [fix] multiple minor formatting, docstrings and comments * MCOL-5594: Add new CMAPI transaction manager. - [add] TransactionManager ContextDecorator to manage transactions in less code and in one place - [add] TransactionManager to cli cluster stop command and to API cluster shutdown command - [fix] id -> txn_id in ClusterHandler class - [fix] ClusterHandler.shutdown class to use inside existing transaction - [add] docstrings in multiple places * MCOL-5594: Review fixes.
This commit is contained in:
@ -262,6 +262,41 @@ class MCSProcessManager:
|
||||
"""No operation. TODO: looks like useless."""
|
||||
cls.process_dispatcher.noop()
|
||||
|
||||
@classmethod
|
||||
def gracefully_stop_dmlproc(cls) -> None:
|
||||
"""Gracefully stop DMLProc using DBRM commands."""
|
||||
logging.info(
|
||||
'Trying to gracefully stop DMLProc using DBRM commands.'
|
||||
)
|
||||
try:
|
||||
with DBRM() as dbrm:
|
||||
dbrm.set_system_state(
|
||||
['SS_ROLLBACK', 'SS_SHUTDOWN_PENDING']
|
||||
)
|
||||
except (ConnectionRefusedError, RuntimeError):
|
||||
logging.error(
|
||||
'Cannot set SS_ROLLBACK and SS_SHUTDOWN_PENDING via DBRM, '
|
||||
'graceful auto stop of DMLProc failed. '
|
||||
'Try a regular stop method.'
|
||||
)
|
||||
raise
|
||||
|
||||
@classmethod
|
||||
def is_service_running(cls, name: str, use_sudo: bool = True) -> bool:
|
||||
"""Check if MCS process is running.
|
||||
|
||||
:param name: mcs process name
|
||||
:type name: str
|
||||
:param use_sudo: use sudo or not, defaults to True
|
||||
:type use_sudo: bool, optional
|
||||
:return: True if mcs process is running, otherwise False
|
||||
:rtype: bool
|
||||
"""
|
||||
return cls.process_dispatcher.is_service_running(
|
||||
cls._get_prog_name(name), use_sudo
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def start(cls, name: str, is_primary: bool, use_sudo: bool) -> bool:
|
||||
"""Start mcs process.
|
||||
@ -299,20 +334,9 @@ class MCSProcessManager:
|
||||
# TODO: do we need here force stop DMLProc as a method argument?
|
||||
|
||||
if is_primary and name == 'DMLProc':
|
||||
logging.info(
|
||||
'Trying to gracefully stop DMLProc using DBRM commands.'
|
||||
)
|
||||
try:
|
||||
with DBRM() as dbrm:
|
||||
dbrm.set_system_state(
|
||||
['SS_ROLLBACK', 'SS_SHUTDOWN_PENDING']
|
||||
)
|
||||
cls.gracefully_stop_dmlproc()
|
||||
except (ConnectionRefusedError, RuntimeError):
|
||||
logging.error(
|
||||
'Cannot set SS_ROLLBACK and SS_SHUTDOWN_PENDING '
|
||||
'using DBRM while trying to gracefully auto stop DMLProc.'
|
||||
'Continue with a regular stop method.'
|
||||
)
|
||||
# stop DMLProc using regular signals or systemd
|
||||
return cls.process_dispatcher.stop(
|
||||
cls._get_prog_name(name), is_primary, use_sudo
|
||||
|
Reference in New Issue
Block a user