3 ms·
I worked with a greybeard that instilled in me that when we were about to do some RAID maintenance that we would always run sync twice. The second to make sure
by kami23 10mo ago
I worked with a greybeard that instilled in me that when we were about to do some RAID maintenance that we would always run sync twice. The second to make sure it immediately returns. And I added a third for my own anxiety.
- deleted 10mo ago[deleted]
- zabzonk 10mo agoit's not just a good idea for raid
- kami23 10mo agoOh definitely not, I do it on every system that I've needed it to be synced before I did something. We were just working at a place that had 2k+ physical servers with 88 drives each in RAID6, so that was our main concern back then. I have been passing my anxieties about hardrives to junior engineers for a decade now.
- wmf 10mo agoYou need to sync twice because Unix is dumb: "According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done." https://man7.org/linux/man-pages/man2/sync.2.html https://man7.org/linux/man-pages/man2/sync.2.html
- 1718627440 10mo ago> Unix is dumb I don't know. Now async I/O is all the rage and that is the same idea.
- marcosdumay 10mo agoThe syscall is literally called "sync", though.
- 1718627440 10mo agoI think it is a way of the OS to shoehorn async into a synchronously written application.
- wmf 10mo agoIf they had a sync() system call and a wait_for_sync_to_finish() system call then you'd be right. But they didn't have those.
- 1718627440 10mo agohttps://news.ycombinator.com/item?id=46268127 https://news.ycombinator.com/item?id=46268127 (To quote yourself :-) )
- amelius 10mo agoThen how do you know the writes are done after the second sync?
- wmf 10mo agoAFAIK multiple syncs can't happen at the same time so the second sync implicitly waits for the first one to complete.
- amelius 10mo agoIf it was that simple, then why doesn't sync just do 2x sync internally?
- wakawaka28 10mo agoIf I had to guess, it is just extra work to do it twice, and you may not need to wait for it for some use cases. The better way would be to add a flag or alternative function to make the sync a blocking operation in the first place.
- wmf 10mo agoWhy is creat() missing the e? Why does an FTP server connect back to the client?
- lowbloodsugar 10mo agosync; sync; halt