This bug seems to have snuck in there with the introduction of walmethods. AFAICT we are testing the result of sync() backwards, so whenever a partial segment exists for pg_receivewal, it will fail. It will then unlink the file, so when it retries 5 seconds later it works.
It also doesn't log the failure. Oops.
Attached patch reverses the check, and adds a failure message. I'd appreciate a quick review in case I have the logic backwards in my head...