diff --git a/oam/install_scripts/columnstore-post-install.in b/oam/install_scripts/columnstore-post-install.in index 2f033c357..930c6a929 100755 --- a/oam/install_scripts/columnstore-post-install.in +++ b/oam/install_scripts/columnstore-post-install.in @@ -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 diff --git a/oam/install_scripts/mariadb-columnstore-start.sh b/oam/install_scripts/mariadb-columnstore-start.sh index 79d094ba3..aaeaacd7e 100644 --- a/oam/install_scripts/mariadb-columnstore-start.sh +++ b/oam/install_scripts/mariadb-columnstore-start.sh @@ -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 diff --git a/oam/install_scripts/mcs-loadbrm.py.in b/oam/install_scripts/mcs-loadbrm.py.in index 53d0d5614..fcde3064f 100755 --- a/oam/install_scripts/mcs-loadbrm.py.in +++ b/oam/install_scripts/mcs-loadbrm.py.in @@ -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)