1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-02 06:13:16 +03:00

Merge pull request #1472 from jmrojas2332/MCOL-4314-develop

MCOL-4314 shared storage manager cluster initialization fix.
This commit is contained in:
Roman Nozdrin
2020-09-25 18:55:22 +03:00
committed by GitHub
3 changed files with 35 additions and 18 deletions

View File

@@ -302,25 +302,23 @@ if [ ! -z "$MCS_USE_S3_STORAGE" ] && [ $MCS_USE_S3_STORAGE -eq 1 ]; then
fi
#change ownership/permissions to be able to run columnstore as non-root
chown -R mysql:mysql /var/log/mariadb/columnstore
chown -R mysql:mysql /etc/columnstore
chown -R mysql:mysql /var/lib/columnstore
chown -R mysql:mysql /tmp/columnstore_tmp_files
chmod 777 /tmp/columnstore_tmp_files
chmod 777 /dev/shm
# TODO: Remove conditional once container dispatcher uses non-root by default
if [ $(running_systemd) -eq 0 ]; then
chown -R mysql:mysql /var/log/mariadb/columnstore
chown -R mysql:mysql /etc/columnstore
chown -R mysql:mysql /var/lib/columnstore
chown -R mysql:mysql /tmp/columnstore_tmp_files
chmod 777 /tmp/columnstore_tmp_files
chmod 777 /dev/shm
fi
systemctl cat mariadb-columnstore.service > /dev/null 2>&1
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
# prevent clusters using shared storage from initializing columnstore more than once
IFLAG=/var/lib/columnstore/storagemanager/cs-initialized
mkdir -p /var/lib/columnstore/storagemanager
chown -R mysql:mysql /var/lib/columnstore/storagemanager
if [ ! -e $IFLAG ]; then
touch $IFLAG
echo "Populating the engine initial system catalog."
systemctl start mariadb-columnstore
fi
echo "Populating the engine initial system catalog."
systemctl start mariadb-columnstore
fi
if [ $stop_mysqld -eq 1 ];then

View File

@@ -2,6 +2,11 @@
# This script allows to gracefully start MCS
# prevent nodes using shared storage manager from stepping on each other when initializing
# flock will open up an exclusive file lock to run atomic operations
exec {fd_lock}>/var/lib/columnstore/storagemanager/storagemanager-lock
flock -n "$fd_lock" || exit 0
/bin/systemctl start mcs-workernode
/bin/systemctl start mcs-controllernode
/bin/systemctl start mcs-primproc
@@ -9,7 +14,9 @@
/bin/systemctl start mcs-exemgr
/bin/systemctl start mcs-dmlproc
/bin/systemctl start mcs-ddlproc
sleep 2
su -s /bin/sh -c 'dbbuilder 7' mysql 1> /tmp/columnstore_tmp_files/dbbuilder.log
su -s /bin/sh -c 'dbbuilder 7' mysql 2> /tmp/columnstore_tmp_files/dbbuilder.log
flock -u "$fd_lock"
exit 0

View File

@@ -81,7 +81,12 @@ if __name__ == '__main__':
# Single-node on S3
if storage.lower() == 's3' and not bucket.lower() == 'some_bucket' and pmCount == 1:
try:
brm_saves_current = subprocess.check_output(['smcat', brm])
if use_systemd:
args = ['su', '-s', '/bin/sh', '-c', f'smcat {brm}', 'mysql']
else:
args = ['smcat', brm]
brm_saves_current = subprocess.check_output(args)
except subprocess.CalledProcessError as e:
# will happen when brm file does not exist
print('{} does not exist.'.format(brm), file=sys.stderr)
@@ -122,6 +127,8 @@ node.".format(e))
if not os.path.exists(dbrmroot):
os.makedirs(dbrmroot)
if use_systemd:
shutil.chown(dbrmroot, USER, GROUP)
current_name = '{}_{}'.format(dbrmroot, e)
@@ -145,14 +152,19 @@ node {}.'.format(primary_address), file=sys.stderr)
print('{} does not exist.'.format(brm), file=sys.stderr)
if brm_saves_current:
cmd = '{} {}{}'.format(loadbrm, dbrmroot, \
if use_systemd:
cmd = 'su -s /bin/sh -c "{} {}{}" mysql'.format(loadbrm, dbrmroot, \
brm_saves_current.decode("utf-8").replace("BRM_saves", ""))
else:
cmd = '{} {}{}'.format(loadbrm, dbrmroot, \
brm_saves_current.decode("utf-8").replace("BRM_saves", ""))
try:
retcode = subprocess.call(cmd, shell=True)
if retcode < 0:
print('{} exits with {}.'.format(cmd, retcode))
sys.exit(1)
for shm_file in glob.glob('/dev/shm/*'):
shutil.chown(shm_file, USER, GROUP)
if use_systemd:
for shm_file in glob.glob('/dev/shm/*'):
shutil.chown(shm_file, USER, GROUP)
except OSError as e:
sys.exit(1)