Make the chat writes durable by group commit
Each write of a chat still goes to the operating system at once, so a
crash of the process loses nothing. After each write, a background
syncfs of the file system of the chat starts unless one runs already,
and the next one starts when it ends. One sync makes every earlier write
durable, so a power loss loses at most the writes after the start of the
last finished sync, and there is never more than one sync at a time.
Memory.Flush returns when the writes before it are durable, so a caller
can make a tool call durable before the tool runs. A failed sync stays
and fails each later flush, because the kernel can drop the data of a
failed write back.
A crash can stop a write in the middle of a line. The open now cuts a
part of a line at the end of the last day file, whose write never
returned, and still refuses one in an earlier file.
golang.org/x/sys gives syncfs on every Linux architecture. The frozen
syscall package has no syncfs number on amd64.
A test kills a writer child process three times during writes of small
and large messages and finds every acknowledged message after each open.
Issue:
5daf23e