Comment 4 for bug 1263476

Revision history for this message
Ryan Gordon (ryan-5) wrote :

Hi,

I went ahead and tried that, initially I got this:

/mysql//bin/wsrep_sst_xtrabackup-v2: line 413: lsof: command not found
grep: illegal option -- E
Usage: grep [-c|-l|-q] [-r|-R] -hHbnsviw pattern file . . .
/mysql//bin/wsrep_sst_xtrabackup-v2: line 413: lsof: command not found
grep: illegal option -- E

I confirmed that lsof did exist:

# which lsof
/opt/local/bin/lsof

The problem is that xtrabackup-v2 sst is started with this PATH: /usr/sbin:/sbin:/mysql//bin:/sbin:/usr/sbin:/bin:/usr/bin:/mysql/bin

Perhaps this is a separate bug because we correctly start MySQL with this path: /opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin:/mysql/bin

As a workaround I hardcoded it as this: /opt/local/bin/lsof -i :$PORT | /opt/local/bin/grep LISTEN | /opt/local/bin/grep -qE 'socat|nc' && break

After applying that workaround I'm not entirely sure this is still working correctly.

lsof -i looks for a file in this format:

* Displaying file information for all processes..
PID PROCESS FILE/DEVICE
-----------------------------------------------------------------
83620 socat /path/to/log/file.log
83621 xbstream /path/to/log/file.log

so unfortunately lsof -i :4444 will never return anything because it needs to be in the format of a file.

However lsof -p 4444 will work for example:
# lsof -o 4444
* Displaying process information for port 4444..
PID PROCESS IP PORT
-----------------------------------------------------------------
16402 socat 0.0.0.0 4444

It looks like if we use the following the command will work correctly:
lsof -o $PORT | grep -qE 'socat|nc' && break