oetiker/znapzend

Mysql mariadb znapzend pre/post-snap-command docs fix.

Opened this issue · 1 comments

Little fix in docs znapzendzetup

pre-snap-command  = /opt/oep/mariadb/bin/mysql -e "set autocommit=0;flush tables with read lock;\\! /bin/sleep 600" &  /usr/bin/echo $! > /tmp/mariadblock.pid ; sleep 10
post-snap-command = /usr/bin/kill `/usr/bin/cat /tmp/mariadblock.pid`;/usr/bin/rm /tmp/mariadblock.pid

In my opinion you must use pkill -P. This fix kill only child so that kill sleep 600 command running under mysql.
post-snap-command = /usr/bin/pkill -P `/usr/bin/cat /tmp/mariadblock.pid`;/usr/bin/rm /tmp/mariadblock.pid

In my case when post-snap-command kill only mysql -e ... the child process sleep 600 still working

root        1363  0.0  0.0  19060  6720 pts/3    S    11:04   0:00 /usr/bin/mysql -e set autocommit=0;fl.......
root        1366  0.0  0.0   5620   960 pts/3    S    11:04   0:00  \_ /usr/bin/sleep 600

[run post-snap-command]

root        1366  0.0  0.0   5620   960 pts/3    S    11:04   0:00 /usr/bin/sleep 600

All tables is locking until sleep ends ;(
Probably the system command \\!sleep 600 running inside mariadb keeps the mysql session going.

When you pkill -P parent_pid system command sleep all pre-snap-command return 0, so there should be no problems with exit status testing...

[root@test ~]# mysql -e "flush  tables with read lock; \\! sleep 600" ; echo $? 
[in other console pkill -P parent_process_id ]
0

(mariadb Ver 15.1 Distrib 10.5.22-MariaDB, for Linux (x86_64) using EditLine wrapper)

Makes sense to me, at least on Linux (IIRC pkill is not guaranteed with same semantics everywhere). I had a similar issue in a different project.