From: Anderson A. Giacomolli Date: Fri, 6 Nov 2026 21:57:56 +0000 (-0300) Subject: Make the chat writes durable by group commit X-Git-Url: https://git.giacomolli.uk/onechat/commitdiff_plain/2532718d5288e1a2586fe5716cc41bb2a0210e16?ds=sidebyside;hp=2532718d5288e1a2586fe5716cc41bb2a0210e16 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 ---