rsync suddenly hanging indefinitely during transfers

Viewed 70610

For the past few years, I have been using an rsync one-liner to back up important folders on my Mac Mini desktop (OSX 10.9, 2.5 GHz i5, 4 GB RAM) to a FreeNAS box (0.7.2 Sabanda revision 5266, Pentium D 2.66 GHz, 822MiB RAM [reported by the system, I think there's 1 GB in there]). I am running an rsync daemon on the FreeNAS box. Recently, these transfers have been hanging indefinitely. I have done the usual Google-fu and am unable to identify the source of the problem or a solution.

The one-liner is:

rsync -rvOlt --exclude '.DS_Store'                                  \
      --exclude '.com.apple.timemachine.supported'                  \
      --delete /Volumes/Storage/Music/Albums/ 192.168.1.100::albums

I have tried enabling -vvv and --progress, but there is no pattern that I can discern between what hangs and what doesn't. Heck, if I retry, the same file might hang at a different point during the transfer or not at all. A dry run (-n) does not always succeed either. The only "success" I've had is implementing a timeout (--timeout=10) and rerunning the command over and over. Eventually, I creep along, but with no guarantee of success and at a pace that is unacceptable. I've reached a point where I have one file that I can't get past.

The Mac Mini is connected to my router via 5 GHz. The FreeNAS box is wired into that same router on a 100 mbit port. When transfers are actually going, rsync --progress reports 2.5-4 MB/s. According to --progress, a hang is literally just that—no data transfer is occurring as far as I can tell.

I need help with both the diagnostics and the solution.

14 Answers

Try using --whole-file/-W. This command disables the rsync delta-transfer algorithm. That is what worked for us (WSL to OSX)

our full sync flags were -avWPle

(e was because we were using ssh, and that has to be the last flag)

Just had a similar problem while doing rsync from harddisk to a FAT32 USB drive. rsync froze already in less than a second in my case and did not react at all after that ... left it with CTRL+C.

Found out that the problem was a combination of usage of hardlinks on the harddisk and having FAT32 filesystem on the USB drive, which does not support hardlinks.

Formatting the USB drive with ext4 solved the problem for me.

In my situation rsync was not actually failing.

I have regular server backups which transfers large files over 500GB+ and have --append-verify or --checkusm over ssh parameters specified.

What I have found upon analysis is that once the client side completes it's file checks then the server side checks start. Which means while the server is doing it's checks the client side will appear hanged and frozen - run htop on the server to rsync working away.

This is likely a non issue if rsync is run in deamon mode on the server and using the rsync protocol instead of ssh for transfers.

On related note, this very LONG wait would trigger SSH timeout and a rsync: connection unexpectedly closed (254 bytes received so far) [sender] error message, sollution is to add ClientAliveInterval 120 and ClientAliveCountMax 720 to /etc/ssh/sshd_config.

I've seen this quite often on 3.0.9 on a directory with hardlinks, but it also happened on 3.1.3.

There is a nice analysis in Debian bug 820916: when its internal sockets are congested with errors, rsync could go into a deadlock.

This might have been fixed in a 3.2 release just a few days ago (Jun 2020):

Avoid a hang when an overabundance of messages clogs up all the I/O buffers.

The only good workaround I can think of is, if the problem is not persistent, then put timeout in front of it: timeout rsync <args> <source> <destination>, then retry. If it is persistent for you, you're the lucky one who can debug it :D

It also happens when the user on target machine has not write permissions on target folder.
You can try giving write permission to others target folder:

sudo chmod -R o+w /path/to/target-folder

In my case, it was the IPC (Intrusion Protection Component) in our firewall. It sees all the TCP SYN packets as a flood attack and kills the connection. I left a rsync over NFS session open and turned off the IPC for the servers firewall rule and it starting working again right away.

rsync -ravh /source /destination

When it happened I was not able to kill the rsync session. It locked up the NFS mount and I would have to reboot the client machine to get it to work again. The strange thing is it would copy some files over then all of a sudden stop. It always seemed to stop on the same file. So I was looking for file issues, permission issues, TCP offloading issues, tried removing the -v in the rsync call. If you are having this issue at least in my case it even happened with a simple.

cp -rp /source /destination 

So I knew then to start looking at other factors. So if you have any sort of intrusion protection on a firewall or router between the servers you can try turning that off temporarily to see if it solves your issue as well.

Had rsync hanging issue on Ubuntu 16. None of the options above helped. The problem was in the source drive (external SSD) which suddenly became faulty. I tried several disk checks, but all of them stuck. Ended up rebooting the system and disk suddenly became accessible again.

Holger Ohmacht aka h8ohmh / 8ohmh:

The problem lies in the filesystem buffer / usage of the interworking of harddisk/hw so far as I could investigate.

Temporal solution for local drives (eg. USB3<->HD) : A script which is polling the changing disk space. If no changing free disk space then rsync is stalled and has to be restarted

cmd="rsync -aW --progress --stats --preallocate --super \ <here your source dir> \ <here your dest dir>" eval "$cmd" &
rm ./ndf.txt rm ./odf.txt while [[ 0 == 0 ]]; do df > ./ndf.txt cmp ./odf.txt ./ndf.txt res="$?" echo "$res" if [[ $res == 0 ]]; then echo "###########################################" ls -al "./ndf.txt" ls -al "./odf.txt" killall rsync eval "$cmd" & else cp ./ndf.txt ./odf.txt fi sleep 60 done
Change <source dir> etc to your paths!

In my case it is always stalling by usage of rsync's --preallocate option (normally because of better disk performance and rescueing continuous blocks), so as long as the disk and filesystem drivers not reworked there just this solution

Related