frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: db-branch – database branches in seconds for AI agents and CI, via ZFS

https://github.com/db-branch/db-branch
7•nu_nu11•4h ago

Comments

nu_nu11•4h ago
Hey HN! I've read HN for years but this is my first post.

db-branch uses ZFS copy-on-write to create, destroy, and reset MySQL and PostgreSQL clones in seconds, even for terabyte-scale databases. It's self-hosted and doesn't depend on any cloud vendor.

Background

Per-PR preview environments are common now, but the database is usually still a shared one. PlanetScale, Neon, and Aurora's fast clone solved this with Git-like branching, even for huge datasets: cut a branch in an instant, throw it away when you're done.

The catch is that these are managed services tied to specific cloud vendors. Cost can be a barrier, fully air-gapped (on-prem) environments have constraints, and sometimes you just want the same workflow on your laptop. db-branch is meant for those cases.

There's one more use case I care about: letting an AI agent such as Claude Code freely experiment with SQL against a database that looks like real data. Pointing an agent at production or staging directly is dangerous. With a branch, even if the agent runs something destructive (a DROP, a massive UPDATE), you just throw the branch away or roll back to a snapshot. Being a disposable DB sandbox for AI agents is one of the goals of this project.

Architecture

Storage and processes: Using ZFS snapshot/clone, db-branch instantly creates a dataset from a snapshot of a cleanly shut down MySQL/PostgreSQL instance, then starts a process for it using a systemd template unit, switching ports per branch. Each branch runs as its own independent DB process.

Dynamic routing: ProxySQL sits in front of the branch processes, so clients don't have to change port numbers. Branches are routed by connecting user or by a query comment (/db_branch=.../). This works for PostgreSQL as well as MySQL, using ProxySQL 3.x's PostgreSQL protocol support.

Clustering: db-branch clusters are built with Raft and ZFS send/recv, and routing inside the cluster is also done by ProxySQL.

Limitations and trade-offs

- How the base snapshot is taken: For consistency, snapshots are taken from a cleanly shut down DB. This doesn't mean stopping your production DB. The idea is to stop a read replica and snapshot that, or to use an instance restored from a regular dump/backup as the base. - Memory is the real cost: CoW keeps disk usage low, but every branch is a separate DB process, so per-process memory grows with the number of branches. So we recommend keeping the DB-side caches (InnoDB buffer pool, PostgreSQL shared_buffers) small and giving most of the memory to the ZFS ARC. Clones share unmodified blocks, so data cached in the ARC is shared across branches, instead of every branch holding its own copy of the same data in its own DB cache. Even so, if you run dozens of branches at the same time, you need to plan the host's RAM accordingly. - Heavy writes still cost disk: CoW only shares blocks that haven't been modified, so a branch that writes a lot consumes that much space.

Features

- Create and destroy MySQL and PostgreSQL branches - Take snapshots of a branch as save points, and restore from them - Upgrade verification for MySQL / PostgreSQL (upgrade version feature) - SQL routing via ProxySQL - Cluster setup - [Commercial module] Recording of executed queries and restore to any point (Lite Plan / History Module)

Try it

You can try it on a local Mac or Windows machine using Multipass: https://github.com/db-branch/db-branch#evaluate-locally-maco...

Monetization and license

To keep the project sustainable, the core branching engine and the clustering feature are released as fully open source, free of charge. More advanced features, namely the per-query recording and restore (History Module), plus enterprise user management, SSO, and auditing, are planned as modules of a commercial plan. Only some of these are available so far, and you can use them for a one-month trial period.

(Whispering: if you're only playing around in the local Multipass environment, you can just tear down the VM and recreate it every month and keep using it basically forever... shhh )

n_u•43m ago
This is interesting. Does it hook into Postgres and MySQL’s MVCC?
t0mas88•39m ago
Postgres 18 has file_copy_method = clone for this, is that used underneath or did you implement your own own?

All AI-generated code should be Open Source

https://jakub.jankiewicz.org/blog/ai-code-open-source/
603•jcubic•3h ago•337 comments

The MacBook Pro's OLED PWM Problem: When a 'Better' Display Becomes Worse to Use

https://macanorak.com/the-macbook-pros-oled-pwm-problem-when-a-better-display-becomes-worse-to-use/
243•MacAnorak•5h ago•139 comments

Emacs Is My Browser

https://joshblais.com/blog/emacs-as-my-browser/
80•nyc111•2h ago•33 comments

Things That Turbo Pascal Is Smaller Than (2011)

https://prog21.dadgum.com/116.html
115•ksec•4h ago•49 comments

SpaceX catches the Starship to end Flight 15

https://www.spacex.com/launches/starship-flight-15
1517•ls612•20h ago•1054 comments

Claude Code and Codex reverse engineered my 1994 Jeep's ECU over a $3 Arduino [video]

https://www.youtube.com/watch?v=WPj3aQ-xxpI
108•envoked•3d ago•51 comments

Understanding Positional Embeddings in Modern LLMs

https://magazine.sebastianraschka.com/p/understanding-positional-embeddings
129•vismit2000•6h ago•3 comments

Notes on Mathematics for Engineers (1959) [pdf]

https://websites.umich.edu/~ners311/CourseLibrary/MathNotes.pdf
11•the-mitr•4d ago•0 comments

Court denies motion to dismiss DRAM price fixing case

https://litnews.ai/articles/garciaguirre-samsung-sk-hynix-micron-dram-conspiracy-suit-survives-di...
406•ybathaee•17h ago•183 comments

A NES emulator written in Odin

https://lucypero.com/lucynes.html
69•frostbyte7•5h ago•15 comments

20 Years of Pyrolog

https://pypy.org/posts/2026/11/20-years-of-pyrolog.html
40•lumpa•3d ago•4 comments

What thousands of conversations look like inside a language model

https://operator0x.com/field-notes/qwen-conversation-state-space/
72•josip208•2d ago•23 comments

Why did some Apollo missions carry a grenade launcher?

https://space.stackexchange.com/questions/37775
159•Skyfall106•9h ago•118 comments

The Hypertext Transfer Protocol Status Code 483 (I'm Not a Freezer)

https://datatracker.ietf.org/doc/draft-banffy-httpbis-not-a-freezer/
65•rbanffy•3h ago•30 comments

Lutnick Pushed to Weaken Chip Rules That Overlap with His Family Business

https://www.nytimes.com/2026/11/15/us/politics/lutnick-pushed-to-weaken-chip-rules-that-overlap-w...
272•JumpCrisscross•6h ago•119 comments

The Telephone Changed the World

https://lithub.com/how-the-telephone-changed-the-world/
35•NaOH•19h ago•12 comments

Chasing an audio artifact on power loss

https://subalpinecircuits.com/chasing-an-audio-artifact-on-power-loss/
39•ireflect•2d ago•3 comments

How to read codes from (many) IR remote controls with as little code as possible

https://bitbanksoftware.blogspot.com/2026/11/how-to-read-codes-from-many-ir-remote.html
33•speckx•3d ago•6 comments

How did Woz write the Apple 1 BASIC before building the computer?

https://retrocomputing.stackexchange.com/questions/17957
285•Skyfall106•19h ago•146 comments

Handwritten 200-year-old dismissal notice found on roof tile

https://www.bbc.co.uk/news/articles/c6jdmdzv25r9o
56•nephihaha•2d ago•38 comments

My favourite modern NES games

https://jordi.inversethought.com/blog/25-of-my-favourite-modern-nes-games/
176•jordigh•15h ago•30 comments

Show HN: Carton Clock – A working pendulum clock made from empty drink cartons

https://www.niklasroy.com/carton-clock/
48•r0r0•2d ago•2 comments

Open-Source HF Communications for Remote Communities and Experimenters

https://www.ardc.net/rhizomaticas-hermes-and-mercury-expand-open-source-hf-communications-for-rem...
68•tejtm•4d ago•9 comments

A family tree of software job titles

https://zwischenzugs.com/2026/11/03/a-family-tree-of-software-job-titles/
400•umerf•1d ago•195 comments

Lovable apps expose passport details and more than 200K private messages

https://www.crissyfield.de/research/lovable-en/
953•armcat•1d ago•363 comments

Semicircle Packing

https://rorz.io/writing/semicircle-packing
81•sarreph•2d ago•8 comments

Show HN: db-branch – database branches in seconds for AI agents and CI, via ZFS

https://github.com/db-branch/db-branch
7•nu_nu11•4h ago•3 comments

Disk encryption on NetBSD – achieving secrecy

https://netbsd.org/~nia/disk-encrypt/
85•jaypatelani•12h ago•17 comments

The Evolving Story of How Chemistry Became Biology

https://www.quantamagazine.org/the-evolving-story-of-how-chemistry-became-biology-20261112/
94•pseudolus•2d ago•21 comments

PyPI's redesigned project pages with clearer security signals are now live

https://blog.pypi.org/posts/2026-11-06-ui-updates-complete/
265•rbanffy•1d ago•125 comments