Yet another reminder that you have to think about file IO as a concurrency problem: https://thomask.sdf.org/blog/2019/11/09/take-care-editing-bash-scripts.html
Take care editing bash scripts

Imagine I write the following bash script and call it delay.sh. What do you suppose happens when I run ./delay.sh?#!/bin/bashsleep 30#rm -rf --no-preserve-ro...

In the inverse genre (tailing a log file where readers observing concurrent writes is a feature, not a bug) there's also this terrifying but entertaining lightning talk from @bcantrill: https://www.youtube.com/watch?v=vm1GJMp0QN4&t=2475s
Surge 2013: LightningTalks

YouTube
@pervognsen @bcantrill if only there was an OS that got this significantly more right than the others (it's Windows, Windows gets it significantly more right than the others).
@DirtyPunk @bcantrill Windows certainly has much stricter semantics around sharing. E.g. the equivalent of the mmap truncate SIGBUS wouldn't happen on Windows because SetEndOfFile fails if there are any open mappings, so the truncate would fail if there were concurrent mapping-based readers. But this bondage and discipline philosophy around sharing is a double-edged sword. When you think about it, it's crazy that read permission to a log file can block the log writer from truncating it.

@pervognsen @bcantrill Oh, I'm aware of that, I still think Windows got this right and the people pointing at *that infamous issue* got it wrong.

The only issue there is with UI.

POSIX file handling semantics are *fundamentally broken and you can not build correctness on top of them*.

@pervognsen @bcantrill This is why you can use a file based DB like Access or sqllite on a Windows-to-Windows network drive connection and the same thing is fundamentally not possible on nearly any UNIX.
@DirtyPunk @bcantrill The issue is definitely more than just UI. There's no privilege level which allows someone to read but not map a file on Windows. Both of them require the same GENERIC_READ mode. So if you want to expose a log file as readable to some other process, you as the log writer process have to assume you might _never_ be able to truncate the log. At the very least the NT team should have disaggregated those privileges if open mappings can globally block truncates.

@pervognsen @bcantrill No, I'd still argue they made the right choice, because there is no fundamentally correct way to implement that semantic.

It isn't just UI, it's also developer education, but there's a reason why Windows is pretty much the only OS used in environments with strict regulations around file-based records.

@pervognsen @bcantrill Well, I say "no fundamentally correct way" - but full serializable MVCC semantics would get you there. Now, that I would like to see.