Skip to content

Commit 0411c88

Browse files
committed
[#3559] hammer.py: pkill mariadb_safe before restarting
Attempt to fix `start-stop-daemon: /usr/bin/mysqld_safe is already running`
1 parent 3fa6eb9 commit 0411c88

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

hammer.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,15 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
426426
return exitcode
427427

428428

429+
def wait_for_process_to_start(process_name):
430+
for _ in range(10):
431+
exit_code = execute(f'sudo pidof {process_name}', raise_error=False)
432+
if exit_code == 0:
433+
# Process is there.
434+
break
435+
time.sleep(1)
436+
437+
429438
def wait_for_process_to_exit(process_name):
430439
for _ in range(100):
431440
exit_code = execute(f'sudo pidof {process_name}', raise_error=False)
@@ -1380,10 +1389,11 @@ def _configure_mysql(system, revision, features):
13801389
execute('sudo sed -i "/^skip-networking$/d" /etc/my.cnf.d/mariadb-server.cnf')
13811390
execute('sudo rc-update add mariadb')
13821391
execute('sudo rc-service mariadb stop')
1392+
wait_for_process_to_start('start-stop-daemon') # mysqld_safe
13831393
wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
1394+
execute('sudo pkill -f mysqld_safe', raise_error=False) # If no graceful shutdown, force kill.
13841395
execute('sudo rc-service mariadb setup')
1385-
wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
1386-
execute('sudo rc-service mariadb restart')
1396+
execute('sudo rc-service mariadb restart', raise_error=False)
13871397

13881398
cmd = "echo 'DROP DATABASE IF EXISTS keatest;' | sudo mysql -u root"
13891399
execute(cmd)

0 commit comments

Comments
 (0)