Skip to content

Blog

The Syscalls That Lie

The EINTR retry, the fsync that isn't, and the one call you must never retry.

The POSIX calls at the bottom of every server are not as honest as they look. A read can be cut short by a signal and return having done nothing wrong. An fsync on macOS returns success without actually putting your data on the platter. And retrying a close() that was interrupted can silently destroy a file descriptor another thread just reused. The eighteenth familiar is the thin layer that knows all of this and does the boring, correct thing so the rest of the engine never has to.

Down the Flume

Streaming a whole database over a wire, compressed and checked, without holding it in memory.

Replicating a database means moving a file bigger than memory across a link, and doing it so that it arrives smaller, intact, and without ever loading the whole thing into RAM at either end. The seventeenth familiar is named after the wooden channel that floats logs downstream: you feed a file in one end and it comes out the other, compressed and checked, in bounded memory, at a ratio that turns bandwidth into headroom.

Who Owns the Tree

A JSON-shaped MessagePack value whose copies share nothing.

A search engine moves documents around all day, and in C++ the way you hand one over decides what it costs. The sixteenth familiar is the document value itself, and every document lives in an arena of its own: a reference reaches into it, a move hands it over, and a copy builds a whole new one. When Xapiand needed many threads to share one document, it froze it and shared a pointer instead.

Append Only

A blob store that never overwrites a record, so a crash can only ever cost you the last write.

The scariest moment for a datastore is the one where the power goes out mid-write. If your store overwrites data in place, that moment can shred a record that was already safe. The fifteenth familiar refuses to overwrite a record, ever: it only appends. A crash can lose the write in flight, and nothing else, and that single discipline turns crash safety from a hope into a guarantee of the format.

The Seam

An HTTP/1.1 framework that streams requests in, and buffers replies out unless asked to stream.

Most HTTP frameworks make you think about the server. This one gives you exactly one thing to implement, a handler that takes a request and writes a response, and hides the socket, the parser, and the event loop behind that seam. The fourteenth familiar streams where it has to, on the way in, so a multi-gigabyte restore never sits in memory, and buffers on the way out by default, which is what gives a reply its ETag, its byte ranges and its compression. A reply too big to hold can stream too.