Bus errors, core dumps, and binaries on NFS (2018)
rachelbythebay.com
rachelbythebay.com
`install` basically results in a new inode allowing for processes to keep a handle on the old version of the .so
`cp` copies the content over the old content, keeping the same inode. Now applications that had that .so open won't be happy.
I learn something everyday...
But at least you do get proper error codes that you can handle in a somewhat sane way.
A read our write error for an mmapped file? SIGBUS, game over. Want to handle it? Use a signal handler for SIGBUS, use setjmp before every access to your mmapped region and longmp back from your signal handler. And you thought handling all the failure modes of read/write was ugly.
Use mmap if you absolutely need the performance. Otherwise just don't.
As for the code, if you just can let it crash, prefer that to attempting to handle it, because this kind of handling is even worse to test and debug than normal error code paths.
[1] A simple and efficient implementation of a small database, https://dl.acm.org/doi/abs/10.1145/37499.37517?download=true
If you write your program carefully, you can handle it, but it is way more difficult than handling error codes returned by a read function. You will even have to fight the compiler, because it does not distinguish between RW on manually mmapped data files from other RW; however you may want to just let it crash, because after all your program is also mmapped, including .text and .rodata sections, so it better works correctly -- anyway if the data files are on another partition and/or the application requires to be resilient, this excuse does not hold.
The problem the article mentions is overwritin a binary instead of renaming.
And yes, this should be solved, but some NFS servers don't support it, e.g. AWS's EFS.
In NFS, you can set mounts as 'hard' or 'soft'. If hard, errors will get you stuck until the share is back. You probably don't want that. If soft, you're slightly better off, but remember that the retry settings are all per-mount, and perhaps one size doesn't fit all.
As far as I know, when NFS goes awry, you get the same or similar behavior to a hypothetical HDD/SDD that just explicably decided to no longer do anything for a while. Your processes will be in a D state and won't be killable for a potentially long time.
Every now and then I’d know someone was in the closet because my transceiver’s light would peg and NFS was locked up. Someone had once again bumped the AppleTalk router.