frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Async I/O on Linux in databases

https://blog.canoozie.net/async-i-o-on-linux-and-durability/
74•jtregunna•5h ago

Comments

jtregunna•5h ago
Post talks about how to use io_uring, in the context of building a "database" (a demonstration key-value cache with a write-ahead log), to maintain durability.
tlb•3h ago
The recovery process is to "only apply operations that have both intent and completion records." But then I don't see the point of logging the intent record separately. If no completion is logged, the intent is ignored. So you could log the two together.

Presumably the intent record is large (containing the key-value data) while the completion record is tiny (containing just the index of the intent record). Is the point that the completion record write is guaranteed to be atomic because it fits in a disk sector, while the intent record doesn't?

ta8645•3h ago
It's really not clear in the article. But I _think_ the gains are to be had because you can do the in-memory updating during the time that the WAL is being written to disk (rather than waiting for it to flush before proceeding). So I'm guessing the protocol as presented, is actually missing a key step:

    Write intent record (async)
    Perform operation in memory
    Write completion record (async)
    * * Wait for intent and completion to be flushed to disk * *
    Return success to client
gsliepen•3h ago
But this makes me wonder how it works when there are concurrent requests. What if a second thread requests data that is being written to memory by the first thread? Shouldn't it also wait for both the write intent record and completion record having been flushed to disk? Otherwise you could end up with a query that returns data that after a crash won't exist anymore.
Manuel_D•2h ago
It's not the write ahead log that prevents that scenario, it's transaction isolation. And note that the more permissive isolation levels offered by Postgres, for example, do allow that failure mode to occur.
avinassh•1h ago

    * * Wait for intent and completion to be flushed to disk * *
if you wait for both to complete, then how it can be faster than doing a single IO?
jmpman•3h ago
“Write intent record (async) Perform operation in memory Write completion record (async) Return success to client

During recovery, I only apply operations that have both intent and completion records. This ensures consistency while allowing much higher throughput. “

Does this mean that a client could receive a success for a request, which if the system crashed immediately afterwards, when replayed, wouldn’t necessarily have that request recorded?

How does that not violate ACID?

JasonSage•2h ago
As best I can tell, the author understands that the async write-ahead fails to be a guarantee where the sync one does… then turns their async write into two async writes… but there’s still no guarantee comparable to the synchronous version.

So I fail to see how the two async writes are any guarantee at all. It sounds like they just happen to provide better consistency than the one async write because it forces an arbitrary amount of time to pass.

m11a•1h ago
Yeah, I feel like I’m missing the point of this. The original purpose of the WAL was for recovery, so WAL entries are supposed to be flushed to disk.

Seems like OP’s async approach removes that, so there’s no durability guarantee, so why even maintain a WAL to begin with?

nephalegm•58m ago
Reading through the article it’s explained in the recovery process. He reads the intent log entries and the completion entries and only applies them if they both exist.

So there is no guarantee that operations are committed by virtue of not being acknowledged to the application (asynchronous) the recovery replay will be consistent.

I could see it would be problematic for any data where the order of operations is important, but that’s the trade off for performance. This does seem to be an improvement to ensure asynchronous IO will always result in a consistent recovery.

zozbot234•17m ago
> Does this mean that a client could receive a success for a request, which if the system crashed immediately afterwards, when replayed, wouldn’t necessarily have that request recorded?

Yup. OP says "the intent record could just be sitting in a kernel buffer", but then the exact same issue applies to the completion record. So confirmation to the client cannot be issued until the completion record has been written to durable storage. Not really seeing the point of this blogpost.

nromiun•2h ago
Slightly off topic but anyone knows when/if Google is going to enable io_uring for Android?
ozgrakkurt•2h ago
Great to see someone going into this. I wanted to do a simple LSM tree using io_uring in Zig for some time but couldn't get into it yet.

I always use this approach for crash-resistance:

- Append to the data (WAL) file normally.

- Have a seperate small file that is like a hash + length for WAL state.

- First append to WAL file.

- Start fsync call on the WAL file, create a new hash/length file with different name and fsync it in parallel.

- Rename the length file onto the real one for making sure it is fully atomic.

- Update in-memory state to reflect the files and return from the write function call.

Curious if anyone knows tradeoffs between this and doing double WAL. Maybe doing fsync on everything is too slow to maintain fast writes?

I learned about append/rename approach from this article in case anyone is interested:

- https://discuss.hypermode.com/t/making-badger-crash-resilien...

- https://research.cs.wisc.edu/adsl/Publications/alice-osdi14....

toolslive•1h ago
it's possible to unify the WAL and the tree. There are some append only B-tree implementations. https://github.com/Incubaid/baardskeerder fe.
avinassh•1h ago
There are also CoW B Trees not entirely similar, but kinda same.
toolslive•22m ago
there's a whole class of persistent persistent (the repetition is intentional here) data structures. Some of them even combine performance with elegance.
tobias3•1h ago
I don't get this. How can two(+) WAL operations be faster than one (double the sync IOPS)?

I think this database doesn't have durability at all.

avinassh•1h ago
I don't get this scheme at all. The protocol violates durability, because once the client receives success from server, it should be durable. However, completion record is async, it is possible that it never completes and server crashes.

During recovery, since the server applies only the operations which have both records, you will not recover a record which was successful to the client.

LAC-Tech•54m ago
Great article, but I have a question:

The problem with naive async I/O in a database context at least, is that you lose the durability guarantee that makes databases useful. When a client receives a success response, their expectation is the data will survive a system crash. But with async I/O, by the time you send that response, the data might still be sitting in kernel buffers, not yet written to stable storage.

Shouldn't you just tie the successful response to a successful fsync?

Async or sync, I'm not sure what's different here.

leentee•22m ago
First, I think the article provides false claim, the solution doesn't guarantee durability. Second, I believe good synchronous code is better than bad asynchronous code, and it's way easier to write good synchronous code than asynchronous code, especially with io_uring. Modern NVMe are fast, even with synchronous IO, enough for most applications. Before thinking about asynchronous, make sure your application use synchronous IO well.
jorangreef•7m ago
To be clear, this is different to what we do (and why we do it) in TigerBeetle.

For example, we never externalize commits without full fsync, to preserve durability [0].

Further, the motivation for why TigerBeetle has both a prepare WAL plus a header WAL is different, not performance (we get performance elsewhere, through batching) but correctness, cf. “Protocol-Aware Recovery for Consensus-Based Storage” [1].

Finally, TigerBeetle's recovery is more intricate, we do all this to survive TigerBeetle's storage fault model. You can read the actual code here [2] and Kyle's Jepsen report on TigerBeetle also provides an excellent overview [3].

[0] https://www.youtube.com/watch?v=tRgvaqpQPwE

[1] https://www.usenix.org/system/files/conference/fast18/fast18...

[2] https://github.com/tigerbeetle/tigerbeetle/blob/main/src/vsr...

[3] https://jepsen.io/analyses/tigerbeetle-0.16.11.pdf

The bewildering phenomenon of declining quality

https://english.elpais.com/culture/2025-07-20/the-bewildering-phenomenon-of-declining-quality.html
117•geox•3h ago•140 comments

Why I'm Betting Against AI Agents in 2025 (Despite Building Them)

https://utkarshkanwat.com/writing/betting-against-agents/
76•Dachande663•2h ago•35 comments

Async I/O on Linux in databases

https://blog.canoozie.net/async-i-o-on-linux-and-durability/
74•jtregunna•5h ago•21 comments

The Big LLM Architecture Comparison

https://magazine.sebastianraschka.com/p/the-big-llm-architecture-comparison
76•mdp2021•4h ago•3 comments

Hungary's oldest library is fighting to save books from a beetle infestation

https://www.npr.org/2025/07/14/nx-s1-5467062/hungary-library-books-beetles
133•smollett•3d ago•15 comments

Show HN: ggc – A terminal-based Git CLI written in Go

https://github.com/bmf-san/ggc
13•bmf-san•3d ago•4 comments

Make Your Own Backup System – Part 1: Strategy Before Scripts

https://it-notes.dragas.net/2025/07/18/make-your-own-backup-system-part-1-strategy-before-scripts/
281•Bogdanp•15h ago•90 comments

Show HN: MCP server for Blender that builds 3D scenes via natural language

https://blender-mcp-psi.vercel.app/
36•prono•5h ago•8 comments

I tried vibe coding in BASIC and it didn't go well

https://www.goto10retro.com/p/vibe-coding-in-basic
105•ibobev•4d ago•114 comments

Death by AI

https://davebarry.substack.com/p/death-by-ai
351•ano-ther•20h ago•137 comments

Nobody knows how to build with AI yet

https://worksonmymachine.substack.com/p/nobody-knows-how-to-build-with-ai
394•Stwerner•19h ago•316 comments

Local LLMs versus offline Wikipedia

https://evanhahn.com/local-llms-versus-offline-wikipedia/
266•EvanHahn•18h ago•149 comments

How the 'Minecraft' Score Became Big Business for Its Composer

https://www.billboard.com/pro/how-minecraft-score-became-big-business-for-composer/
4•tunapizza•3d ago•1 comments

Borg – Deduplicating archiver with compression and encryption

https://www.borgbackup.org/
68•rubyn00bie•8h ago•23 comments

Beyond Meat fights for survival

https://foodinstitute.com/focus/beyond-meat-fights-for-survival/
96•airstrike•11h ago•204 comments

How to run an Arduino for years on a battery (2021)

https://makecademy.com/arduino-battery
60•thunderbong•3d ago•18 comments

Roman Roads Research Association (UK)

https://www.romanroads.org/index.html
14•countrymile•4h ago•3 comments

Mushroom learns to crawl after being given robot body (2024)

https://www.the-independent.com/tech/robot-mushroom-biohybrid-robotics-cornell-b2610411.html
128•Anon84•3d ago•35 comments

Will the Fear of Being Confused for AI Mean That We Will Now Write Differently?

https://3quarksdaily.com/3quarksdaily/2025/06/will-the-fear-of-being-confused-for-ai-mean-that-we-will-now-write-differently.html
14•bryanrasmussen•5h ago•28 comments

AI is killing the web. Can anything save it?

https://www.economist.com/business/2025/07/14/ai-is-killing-the-web-can-anything-save-it
38•edward•1h ago•43 comments

What were the earliest laws like?

https://worldhistory.substack.com/p/what-were-the-earliest-laws-really
83•crescit_eundo•4d ago•31 comments

Matterport walkthrough of the original Microsoft Building 3

https://my.matterport.com/show/?m=SZSV6vjcf4L
43•uticus•3d ago•27 comments

Open-Source BCI Platform with Mobile SDK for Rapid Neurotech Prototyping

https://www.preprints.org/manuscript/202507.1198/v1
12•GaredFagsss•3d ago•1 comments

Ring introducing new feature to allow police to live-stream access to cameras

https://www.eff.org/deeplinks/2025/07/amazon-ring-cashes-techno-authoritarianism-and-mass-surveillance
282•xoa•13h ago•131 comments

Rethinking CLI interfaces for AI

https://www.notcheckmark.com/2025/07/rethinking-cli-interfaces-for-ai/
169•Bogdanp•18h ago•74 comments

The curious case of the Unix workstation layout

https://thejpster.org.uk/blog/blog-2025-07-19/
93•ingve•19h ago•39 comments

“Bypassing” specialization in Rust

https://oakchris1955.eu/posts/bypassing_specialization/
34•todsacerdoti•3d ago•16 comments

Piano Keys

https://www.mathpages.com/home/kmath043.htm
58•gametorch•4d ago•57 comments

A Treatise for One Network – Anonymous National Deliberation [pdf]

https://simurgh-beau.github.io/
8•simurgh_beau•3d ago•3 comments

How we tracked down a Go 1.24 memory regression

https://www.datadoghq.com/blog/engineering/go-memory-regression/
173•gandem•2d ago•10 comments