[MDEV-13758] Galera with rsync on FreeBSD broken Created: 2017-09-07  Updated: 2017-09-11  Resolved: 2017-09-11

Status: Closed
Project: MariaDB Server
Component/s: Galera, Galera SST, Platform FreeBSD
Affects Version/s: 10.2.7
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Vincent Milum Jr Assignee: Andrii Nikitin (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Environment:

FreeBSD 10.3-STABLE, MariaDB running inside of a dedicated jail with no other changes/packages


Issue Links:
Duplicate
duplicates MDEV-10432 Remove bash/lsof dependencies from sc... Closed

 Description   

The FreeBSD specific patch for rsync Galera SST doesn't work.

https://github.com/MariaDB/server/commit/cf1b0c1ace3584fcd807e0643d30956baa5de2c2#diff-ce1fe90d058fac6e05405aced56e6f83

local port_info=$(netstat -46lp $\{rsync_port\} 2>/dev/null | \
grep ":$\{rsync_port\}")

netstat -p on FreeBSD is for protocol, not port number or program/PID. This command always results in the following error message being sent to /dev/null

netstat: 4444: unknown or uninstrumented protocol

From man:

     -f	address_family,	-p protocol
	   Limit display to those records of the specified address_family or a
	   single protocol.  The following address families and	protocols are
	   recognized:
 
	   Family		       Protocols
	   inet	(AF_INET)	       divert, icmp, igmp, ip, ipsec, pim,
				       sctp, tcp, udp
	   inet6 (AF_INET6)	       icmp6, ip6, ipsec6, rip6, tcp, udp
	   pfkey (PF_KEY)	       pfkey
	   netgraph, ng	(AF_NETGRAPH)  ctrl, data
	   unix	(AF_UNIX)
	   link	(AF_LINK)
 
	   The program will complain if	protocol is unknown or if there	is no
	   statistics routine for it.

Additionally, specifying both -4 and -6 at the same time doesn't work. The latter will overwrite the former. If it is specified as netstat -46, only IPv6 is used. If it is specified as netstat -64, only IPv4 is used.

One other note: there is no mention in the FreeBSD man page of netstat being able to return PID at all, which is the whole point of this call to begin with. Searching around online, everyone is suggesting using lsof to get this information, which is exactly what was happening BEFORE this broken OS specific patch was applied.



 Comments   
Comment by Bernard Spil [ 2017-09-11 ]

There's an error in the script I supplied. It should be ` sockstat`, not `netstat`

https://www.freebsd.org/cgi/man.cgi?query=sockstat
```
-4 Show AF_INET (IPv4) sockets.
-6 Show AF_INET6 (IPv6) sockets.
-p ports Only show Internet sockets if the local or foreign port num-
ber is on the specified list. The ports argument is a comma-
separated list of port numbers and ranges specified as first
and last port separated by a dash.
```

Comment by Andrii Nikitin (Inactive) [ 2017-09-11 ]

The issue was addressed in last comment at https://github.com/MariaDB/server/pull/205 , but somehow the fix escaped final patch.
So `netstat` must be just replaced with `sockstat` call in provided line.

Comment by Andrii Nikitin (Inactive) [ 2017-09-11 ]

Actually I do see sockstat in
https://github.com/MariaDB/server/blame/10.2/scripts/wsrep_sst_rsync.sh#L68
https://github.com/MariaDB/server/blame/10.3/scripts/wsrep_sst_rsync.sh#L68

So you may need this commit as well
https://github.com/MariaDB/server/commit/44ccb8f29ea82d913ec1b55b61c8bbc7c64738a5

So I will close this as 'cannot reproduce'

Generated at Thu Feb 08 08:08:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.