You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-05 16:15:50 +03:00
MCOL-5218: Additional fix to mcs-loadbrm and mcs-savebrm + postinstall.
[fix] bug in detecting primary. [fix] minor bugs. [add] not getting meta on secondaries if no cmapi available on primary node. [fix] postinstall script to mask mariadb-columnstore service on multinode configurations.
This commit is contained in:
@@ -367,6 +367,14 @@ fi
|
|||||||
|
|
||||||
systemctl cat mariadb-columnstore.service > /dev/null 2>&1
|
systemctl cat mariadb-columnstore.service > /dev/null 2>&1
|
||||||
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
||||||
|
|
||||||
|
# mask mariadb-columnstore service to prevent starting services and dbbuilder
|
||||||
|
# after reinstallation on multinode configurations
|
||||||
|
num_workers=$(grep NumWorkers /etc/columnstore/Columnstore.xml | tr -dc '0-9')
|
||||||
|
if [[ $num_workers > 1 ]]; then
|
||||||
|
systemctl mask mariadb-columnstore
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p @ENGINE_DATADIR@/storagemanager
|
mkdir -p @ENGINE_DATADIR@/storagemanager
|
||||||
chown -R mysql:mysql @ENGINE_DATADIR@/storagemanager
|
chown -R mysql:mysql @ENGINE_DATADIR@/storagemanager
|
||||||
IFLAG=@ENGINE_DATADIR@/storagemanager/storagemanager-lock
|
IFLAG=@ENGINE_DATADIR@/storagemanager/storagemanager-lock
|
||||||
|
@@ -62,14 +62,18 @@ def get_unverified_context():
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
def cmapi_available():
|
def cmapi_available(host=LOCALHOST):
|
||||||
"""Check if CMAPI server is running.
|
"""Check if CMAPI server is running.
|
||||||
|
|
||||||
|
:param host: host address to check
|
||||||
|
:type host: str
|
||||||
:return: is CMAPI running or not
|
:return: is CMAPI running or not
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
logging.debug('Detecting CMAPI is up and running.')
|
logging.debug(
|
||||||
url = 'https://{}:{}/notfound'.format(LOCALHOST, API_PORT)
|
'Detecting CMAPI is up and running on {}.'.format(host)
|
||||||
|
)
|
||||||
|
url = 'https://{}:{}/notfound'.format(host, API_PORT)
|
||||||
request = Request(method='POST', url=url)
|
request = Request(method='POST', url=url)
|
||||||
ctx = get_unverified_context()
|
ctx = get_unverified_context()
|
||||||
try:
|
try:
|
||||||
@@ -189,6 +193,8 @@ def is_node_primary(conf_root):
|
|||||||
is_primary = dict_response.get('is_primary', False)
|
is_primary = dict_response.get('is_primary', False)
|
||||||
if is_primary and is_primary in ('True', 'true'):
|
if is_primary and is_primary in ('True', 'true'):
|
||||||
is_primary = True
|
is_primary = True
|
||||||
|
else:
|
||||||
|
is_primary = False
|
||||||
return is_primary
|
return is_primary
|
||||||
|
|
||||||
logging.info('Trying to detect primary without cmapi running.')
|
logging.info('Trying to detect primary without cmapi running.')
|
||||||
@@ -206,7 +212,7 @@ def get_meta(conf_root, meta_type):
|
|||||||
:return: meta data
|
:return: meta data
|
||||||
:rtype: bytes
|
:rtype: bytes
|
||||||
"""
|
"""
|
||||||
logging.info('Pulling {meta_type} from the primary node.')
|
logging.info('Pulling {} from the primary node.'.format(meta_type))
|
||||||
primary_address = conf_root.find('./DBRM_Controller/IPAddr').text
|
primary_address = conf_root.find('./DBRM_Controller/IPAddr').text
|
||||||
url = 'https://{}:{}/cmapi/{}/node/meta/{}'.format(
|
url = 'https://{}:{}/cmapi/{}/node/meta/{}'.format(
|
||||||
primary_address, API_PORT, API_VERSION, meta_type
|
primary_address, API_PORT, API_VERSION, meta_type
|
||||||
@@ -215,8 +221,7 @@ def get_meta(conf_root, meta_type):
|
|||||||
api_key = get_api_key()
|
api_key = get_api_key()
|
||||||
if len(api_key) == 0:
|
if len(api_key) == 0:
|
||||||
logging.error(
|
logging.error(
|
||||||
'Failed to find API key in {}.'.format(CMAPI_CONFIG_PATH),
|
'Failed to find API key in {}.'.format(CMAPI_CONFIG_PATH)
|
||||||
file=sys.stderr
|
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
headers = {'x-api-key': api_key}
|
headers = {'x-api-key': api_key}
|
||||||
@@ -362,26 +367,37 @@ if __name__ == '__main__':
|
|||||||
is_primary = False
|
is_primary = False
|
||||||
try:
|
try:
|
||||||
is_primary = is_node_primary(config_root)
|
is_primary = is_node_primary(config_root)
|
||||||
|
primary_address = config_root.find(
|
||||||
|
'./DBRM_Controller/IPAddr'
|
||||||
|
).text
|
||||||
# Download BRM files from the primary node via CMAPI.
|
# Download BRM files from the primary node via CMAPI.
|
||||||
if not is_primary:
|
if not is_primary:
|
||||||
meta_elems = ['em', 'journal', 'vbbm', 'vss']
|
if cmapi_available(primary_address):
|
||||||
for meta_type in meta_elems:
|
meta_elems = ['em', 'journal', 'vbbm', 'vss']
|
||||||
meta_data = get_meta(config_root, meta_type)
|
for meta_type in meta_elems:
|
||||||
# Store BRM files locally to load them up
|
meta_data = get_meta(config_root, meta_type)
|
||||||
dbrmroot = BYPASS_SM_PATH
|
# Store BRM files locally to load them up
|
||||||
if not os.path.exists(dbrmroot):
|
dbrmroot = BYPASS_SM_PATH
|
||||||
os.makedirs(dbrmroot)
|
if not os.path.exists(dbrmroot):
|
||||||
if use_systemd:
|
os.makedirs(dbrmroot)
|
||||||
shutil.chown(dbrmroot, USER, GROUP)
|
if use_systemd:
|
||||||
|
shutil.chown(dbrmroot, USER, GROUP)
|
||||||
|
|
||||||
current_name = '{}_{}'.format(dbrmroot, meta_type)
|
current_name = '{}_{}'.format(dbrmroot, meta_type)
|
||||||
|
|
||||||
logging.info(
|
logging.info(
|
||||||
'Saving {} to {}'.format(meta_type, current_name)
|
'Saving {} to {}'.format(
|
||||||
)
|
meta_type, current_name
|
||||||
path = Path(current_name)
|
)
|
||||||
path.write_bytes(meta_data)
|
)
|
||||||
shutil.chown(current_name, USER, GROUP)
|
path = Path(current_name)
|
||||||
|
path.write_bytes(meta_data)
|
||||||
|
shutil.chown(current_name, USER, GROUP)
|
||||||
|
else:
|
||||||
|
logging.info(
|
||||||
|
'Cmapi is not running on primary node. '
|
||||||
|
'Skip loading metafiles.'
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logging.error(
|
logging.error(
|
||||||
|
@@ -173,6 +173,8 @@ def is_node_primary(conf_root):
|
|||||||
is_primary = dict_response.get('is_primary', False)
|
is_primary = dict_response.get('is_primary', False)
|
||||||
if is_primary and is_primary in ('True', 'true'):
|
if is_primary and is_primary in ('True', 'true'):
|
||||||
is_primary = True
|
is_primary = True
|
||||||
|
else:
|
||||||
|
is_primary = False
|
||||||
return is_primary
|
return is_primary
|
||||||
|
|
||||||
logging.info('Trying to detect primary without cmapi running.')
|
logging.info('Trying to detect primary without cmapi running.')
|
||||||
|
Reference in New Issue
Block a user