Sign in

v

@avi.im
1.5K followers 584 following 584 posts

breaking databases @tur.so W1 '21 @recursecenter.bsky.social excited about databases, storage engines and message queues

PostsRepliesMedia
v @avi.im · 21/04/2026
I often get emails asking for ideas (or materials) to learn about distributed systems. I always recommend getting started with Gossip Glomers. Only six challenges, some easy and some difficult, but an absolute top tier fun and learning experience fly.io/dist-sys
gossip glomers
2223
v @avi.im · 17/04/2026
Here is an insane piece of lore inside SQLite's source code I am researching VACUUM and I was studying their code. In VACUUM, SQLite creates a temp file prefixed with `etilqs_` Here is why:
** 2006-10-31:  The default prefix used to be "sqlite_".  But then
** Mcafee started using SQLite in their anti-virus product and it
** started putting files with the "sqlite" name in the c:/temp folder.
** This annoyed many windows users.  Those users would then do a 
** Google search for "sqlite", find the telephone numbers of the
** developers and call to wake them up at night and complain.
** For this reason, the default name prefix is changed to be "sqlite" 
** spelled backwards.  So the temp files are still identified, but
** anybody smart enough to figure out the code is also likely smart
** enough to know that calling the developer will not help get rid
** of the file.
*/
#ifndef SQLITE_TEMP_FILE_PREFIX
# define SQLITE_TEMP_FILE_PREFIX "etilqs_"
#endif
3444106
v @avi.im · 14/04/2026
AI is going to radically change how people learn and upskill. Last week, my fren asked for resources to learn distributed systems. I asked him to try Gossip Glomers. Today he mentioned that he did them all: he prompted GPT to solve them and then verified the solutions 🔥
320
v @avi.im · 25/01/2026
redditor explains why job hunting in tech is exactly like auditioning for acting roles
I have the benefit of having an actress in my life, so I get to watch the process of auditioning.

Auditioning is a crap-shoot. You never really know what the director is looking for. They may have someone in mind already and the whole audition is a courtesy / box-check on some grant program they're operating the theater under. You do your best, you take rejection, you suit up and do it again. She does some additional work: she researches the theaters, keeps her ear to the ground, talks to other actors in the area about their experience (that's easier with actors, where the gigs are one-offs; software engineers aren't moving as fast through industry so you have to build a larger contact web to get a richer picture of who's hiring in your area).

But the biggest thing that controls whether you get a role is if you keep showing up. The role finds you; your control over getting the role (unless you're a big enough name that people recognize it) is minimal.

I know it's not the most comfor
180
v @avi.im · 23/01/2026
In the 90s, Linus Torvalds had a much superior language to write the Linux kernel. But, since he is Finnish, he couldn't Smalltalk
130
v @avi.im · 28/10/2025
I explained about SQLite's neat little trick here about reserved space management per page (5/5) bsky.app/profile/did:...
000
v @avi.im · 28/10/2025
For example, if we use AEGIS-256 with a nonce size of 32 bytes and a 16-byte tag, you'd need extra space for 48 bytes per page. During decryption, you read the tag and nonce from the reserved space and provide them to the decryption algorithm. (4/5)
100
v @avi.im · 28/10/2025
The size of this tag and nonce varies by algorithm. To make space, SQLite uses reserved space per page. Once the page is encrypted, this portion can carry the metadata. (3/5)
100
v @avi.im · 28/10/2025
Since we encrypt each page separately, we should use a different nonce for different pages. Even the same page, when encrypted again, should use a different nonce for better security™️ So during encryption, we generate a secure random nonce every time. (2/5)
100
v @avi.im · 28/10/2025
AEADs provide a verification tag after encryption. For each page, we need a nonce too. Both the nonce & the tag become metadata for an encrypted page So where do you store them? We could store them separately, but it's much better & neater to store them in the page itself (1/5)
SQLite reserved space
240
v @avi.im · 26/10/2025
Btw, SQLite also has `secure_delete` pragma setting which overwrites deleted content with zeros. (9/9)
000
v @avi.im · 26/10/2025
SQLite uses this neat trick for its "reserved space" feature. Extensions can store any data they want in each page without interfering with B Tree operations. Extensions like encryption and checksums need to store extra metadata per page, and they use this reserved space. (8/9)
110
v @avi.im · 26/10/2025
Now, remember how I said cells start from the rightmost end? If you intentionally leave some space at that end before starting the cells, the B Tree would work exactly the same. That space can contain anything, and the B Tree would never touch it since there's no pointer to it. (7/9)
page with reserved space
110
v @avi.im · 26/10/2025
This means garbage data from previous uses can actually get written back to disk. I don't know any other data structure that works like this. (6/9)
100
v @avi.im · 26/10/2025
Calling memset (the API that zeroes every bit) adds latency, so as an optimization, databases might skip it entirely. Similarly, a deletion of cell is just removing the pointer, but the data might remain as it is. (5/9)
100
v @avi.im · 26/10/2025
It could have garbage data sitting around, but the page would never access it since no cell pointer references it. Databases also maintain a buffer pool, think of it as a cache of pages loaded from disk. These pages often get reused. (4/9)
100
v @avi.im · 26/10/2025
while the cells themselves grow from right to left, meeting somewhere in the middle. That middle section is logically free space, but here's the interesting part is it can contain any data. Neither the page nor the B Tree cares about what's in there. (3/9)
100
v @avi.im · 26/10/2025
One common way to organize data within a page is the slotted page structure. It starts with a header, followed by a bunch of cell pointers. These pointers reference cells at the end of the page. As you add more data, the pointers grow from left to right (2/9)
100
v @avi.im · 26/10/2025
The B Tree data structure fascinates me. Databases use B Trees to store data on disk, organizing everything into pages that typically range from 4kb to 8kb. All I/O operations happen in units of these pages. The page looks like this... (1/9)
The page strcture
170
v @avi.im · 23/10/2025
seems it works on Maria too mariadb.com/docs/server/...
mariadb.com
Query Limits and Timeouts | MariaDB Documentation
010
v @avi.im · 22/10/2025
docs here: dev.mysql.com/doc/refman/8...
dev.mysql.com
MySQL :: MySQL 8.4 Reference Manual :: 6.5.1.6 mysql Client Tips
010
v @avi.im · 22/10/2025
BTW, SQL_SAFE_UPDATES also auto-enables two other protections: - Limits SELECT to 1,000 rows (no more accidental SELECT * on giant tables) - Caps joins at 1M row combinations You can override these with --select-limit and --max-join-size if needed.
110
v @avi.im · 22/10/2025
Pro database tip: enable `SQL_SAFE_UPDATES` in MySQL to avoid accidental UPDATE/DELETE queries without a WHERE clause. It forces you to use a key or a LIMIT, instead of wiping whole database by mistake at 2:19am.
example usage of mysql safe updates
2172
v @avi.im · 19/10/2025
PS: I'm taking some liberties calling these "shards" — they're really just isolated databases. But I'd still call it a single logical db since they share a schema and present a unified interface, even if you can't query across them.
000
v @avi.im · 19/10/2025
You'd have to handle schema management manually or do it in the application layer. You also can't do mass migrations easily. I call this Limitless Sharding.
100
v @avi.im · 19/10/2025
Even on a tiny machine, I can run millions of SQLite databases. The downsides: You'd only need this at "scale". The entire architecture assumes you don't need cross-shard queries. So this only works for applications where each document is truly an individual entity.
110
v @avi.im · 19/10/2025
Since some of these embedded databases can run as WASM in the browser, each document could sync its own file directly with a backend db with some CRDT. I'd bet this model can handle way more writes per second than a sharded Postgres/MySQL setup.
110
v @avi.im · 19/10/2025
A Figma document could just be stored as a SQLite file in the backend. You'd also need libSQL or SQLite with lightstream for backup/replication.
110
v @avi.im · 19/10/2025
If each document is its own database, it can easily handle all requests without breaking a sweat. Running a million Postgres or MySQL instances sounds crazy and is total overkill. But embedded databases like SQLite, lmdb, and RocksDB fit this perfectly. They're just files!
100
v @avi.im · 19/10/2025
What if we ran disconnected databases that all acted as a single logical db? Think of applications like Notion, Figma, or Google Docs — each document is disconnected from the others. The key insight: each document gets very few write requests since users are making changes manually.
100
v @avi.im · 19/10/2025
Usually there's a proxy that routes queries to the right shards and does aggregation for cross-shard queries. Even though the db is split across multiple machines, it's still logically a single database. They're all "connected". But...what if we flipped this around?
100
v @avi.im · 19/10/2025
Sharding. Database sharding is one of the common techniques to scale a database horizontally. You split the db into small parts called shards and distribute them across machines. Shards are typically in the few hundreds or even thousands (for extremely large databases).
130
v @avi.im · 17/10/2025
on orange site - news.ycombinator.com...
000
v @avi.im · 17/10/2025
SQLite has a page where they explain why they use C. They specifically elaborate on why not Rust www.sqlite.org/whyc....
All that said, it is possible that SQLite might one day be recoded in Rust. Recoding SQLite in Go is unlikely since Go hates assert(). But Rust is a possibility. Some preconditions that must occur before SQLite is recoded in Rust include:


Rust needs to mature a little more, stop changing so fast, and move further toward being old and boring.
Rust needs to demonstrate that it can be used to create general-purpose libraries that are callable from all other programming languages.
Rust needs to demonstrate that it can produce object code that works on obscure embedded devices, including devices that lack an operating system.
Rust needs to pick up the necessary tooling that enables one to do 100% branch coverage testing of the compiled binaries.
Rust needs a mechanism to recover gracefully from OOM errors.
Rust needs to demonstrate that it can do the kinds of work that C does in SQLite without a significant speed penalty.
3251
v @avi.im · 23/09/2025
Lil trivia to remember when it comes to Snapshot Isolation jepsen.io/consistenc...
https://jepsen.io/consistency/models/snapshot-isolation
210
Reposted by v
bryan newbold @bnewbold.net · 19/09/2025
excited to share that we are following through on our earlier commitments and putting together an independent+neutral organization to house the DID PLC system, includes the directory service
docs.bsky.app
Creating an Independent Public Ledger of Credentials (PLC) Directory Organization | Bluesky
The Bluesky Social app is built on an open network protocol that refers to each user by a unique Decentralized Identifier, or DID (a W3C standard). The most popular supported DID method was developed ...
321081333
Reposted by v
Andy Pavlo @andypavlo.bsky.social · 18/09/2025
Next week is the start of @db.cs.cmu.edu's latest seminar series: Future Data Systems @samarchdb.bsky.social and I are hosting speakers from leading systems in the datalake / lakehouse space. Mondays @ 4:30pm ET via Zoom. Open to the public. Videos posted to YouTube: db.cs.cmu.edu/seminars/fal...
Carnegie Mellon University
Future Data Systems
Fall 2025 Seminar Series
Mondays @ 4:30pm ET
14013
v @avi.im · 18/09/2025
read more about SI here: jepsen.io/consistency/...
jepsen.io
Snapshot Isolation
010
v @avi.im · 18/09/2025
The correct answer is either. Transaction B gets a snapshot that may or may not include the changes from A. SI does not provide real time guarantees. If you need that, you need Strict Serializability, which guarantees that transactions are ordered in real time.
Snapshot isolation implies read committed. However, it does not impose any real-time constraints. If process A completes write w, then process B begins a read r, r is not necessarily guaranteed to observe w. Some databases provide real-time variants of snapshot isolation. Compare with strict serializability, which provides a total order and real-time guarantees.
131
v @avi.im · 16/09/2025
Database systems question Assume the database is in snapshot isolation mode. If transaction A updates, and writes x, commits, *then* transaction B starts and reads x's value, then B will see (assume single node for simplcity): 1 - Value before A's write 2 - Value written by A 3 - Either 4 - 🍿
221
v @avi.im · 13/09/2025
Yes! Chroma’s post is how I learned about setsum and I have mentioned in the blog post too!
010
v @avi.im · 13/09/2025
Published a new blog post: Setsum - order agnostic, additive, subtractive checksum post - avi.im/blag/2025/setsum code - github.com/avinassh/...
Setsum - order agnostic, additive, subtractive checksum

Say you’re building a database replication system. The primary sends logical operations to replicas, which apply them in order:

{"op": "add", "id": "apple"}
{"op": "add", "id": "apple"}
{"op": "remove", "id": "orange"}

After the replica processes these changes (add two apples, remove an orange), how do you verify both nodes ended up in the same state? One naive (rather horrible) approach is to dump both states and compare them directly. It’s expensive, impractical, and doesn’t scale!
1133
v @avi.im · 11/09/2025
I wrote a smoll post, you may like this -
avi.im
Rickrolling Turso DB (SQLite rewrite in Rust) - blag
This is a beginner’s guide to hacking into Turso DB (formerly known as Limbo), the SQLite rewrite in Rust. I will explore how to get familiar with Turso’s codebase, tooling and tests
000
v @avi.im · 11/09/2025
Start here with some good first issues -
github.com
tursodatabase/turso
Turso Database is a project to build the next evolution of SQLite. - tursodatabase/turso
100
v @avi.im · 11/09/2025
7. DST (Deterministic Simulation Testing) - very few databases do DST, where everything runs in a simulated universe. You can stop/pause time, get the same random data, and reproduce the most complicated bugs easily. The entire DST code is under 10K lines. So anon, are going to locked in?
100
v @avi.im · 11/09/2025
When in doubt, you can run SQLite and compare how it behaves. 6. It has lots of fancy new stuff that isn't available in SQLite: asynchronous I/O (with io_uring), Materialized Views (IVM), and MVCC.
100
v @avi.im · 11/09/2025
However, it's large enough to have most database features. 4. It is an embedded DB, which makes some things simpler, like running and debugging. 5. The code and features closely follow SQLite. If you run into an issue, you can refer to SQLite. Most LLMs know SQLite's internals.
100
v @avi.im · 11/09/2025
2. It's in Rust. Compared to other systems programming languages, I find Rust to be the easiest to get into and start making changes. The compiler nicely guides you along the way. 3. The codebase is still small; small enough to keep most things in your head.
100
v @avi.im · 11/09/2025
The great lock in is here! For those wanting to get into systems programming and/or database internals, consider hacking on Turso DB, the SQLite rewrite in Rust. Here's why: 1. It's a database!
150
Reposted by v
Tom Ballinger @ballingt.com · 08/09/2025
Hey we're hiring for in-person engineering roles in SF. I really enjoy my job and you might too. Come hang out and build developer tools!
1104