3 ms·
On production systems, it may often be better to completely ignore the problem at this level. On modern hardware if a disk is throwing an io error on write you
by russdill 2y ago
On production systems, it may often be better to completely ignore the problem at this level. On modern hardware if a disk is throwing an io error on write you are having a bad day. I can almost guarantee that while you might happily modify your code so it properly returns the error, there almost certainly aren't test cases for ensuring such situations are handled "correctly", especially since the error will almost certainly not occur in isolation.
It may often be better to handle the issue as a system failure with fanotify. https://docs.kernel.org/admin-guide/filesystem-monitoring.html https://docs.kernel.org/admin-guide/filesystem-monitoring.ht...
- cryptonector 2y agoPlease no. Just handle errors from `close()` when you're writing files. > On modern hardware if a disk is throwing an io error on write you are having a bad day. And how would you know you're having a bad day if apps ignore those errors?
- russdill 2y agoI'm arguing that the proper thing to do here is to kill the process along with whatever else is using the block device. Whether you handle the error or immediately or if you allow the error to occur after a defer, you still are almost certainly not handling it properly and are taking a speed hit for your troubles.
- Too 2y agoAbsolutely not. Imagine a text editor failing when I hit save. Do you really want that to crash the application? No. You want a fallback to ctrl+A ctrl+C, paste into a email and send to yourself. Giving the user a choice to save on a different drive is also a possibility, maybe your thumb drive just got a nudge and lost connection for a second. This is really all normal use cases under normal conditions.
- cryptonector 2y agoUsing signals for this really sucks. Anyways, you don't get to do this now because of backwards-compatibility. Just handle the error.
- nitwit005 2y agoA write failing is totally normal. Unplug an external hard disk.