Pg_branch: Experimental Postgres extension brings Neon-like branching
github.com
github.com
I think this should be really straightforward by using one database as a template for another. This is how Postgres's create database works and it defaults to Template1
https://www.postgresql.org/docs/current/manage-ag-templatedb...
1. The template database can't have active connections during the CREATE DATABASE process.
2. The CREATE DATABASE from a template database can be slow for large DBs.
Why would that be a problem ?
Regular tests shouldn’t assume access to staging/prod, anyway.
The appeal of this project is that it uses CoW (copy on write), so in theory it should be fast to copy as it only maintains writes.
https://developer.salesforce.com/blogs/2022/09/sandboxes-on-...
Yes, we aim to have revenue (as any company) from our paid offering. But not only we're going to keep DBLab Engine open and free, we recently changed the license from AGPLv3 to Apache 2.0, and currently consider making additional pieces open.
Side note: I’ve been loving the Postgres.FM episodes, thanks so much for doing them!
I guess I am inspired by Dolt’s ability to branch and merge: https://github.com/dolthub/dolt
Having it on CI actions would also be amazing.
bcachefs is the only hope left for normal Linux users but it has not landed yet. I am using ZFS for /home (with zstd compression) on LVM on LUKS and my root partition is ext4 on LVM on LUKS.
I considered VDO for LVM because it supports compression but VDO IS A JOKE! https://github.com/dm-vdo/vdo/issues/38
I also use it on servers used in production in RAID 1 (on ones that don't run VMs or Databases) and again, have not had any data loss or filesystem issues.
BTRFS has so much faith that Facebook use it on their server farms. I wouldn't use bcachefs in any kind of critical deployment because it hasn't gone through decades of testing that ext4, xfs and btrfs have gone through.
Would be cool to try using this extension on top of RDS or Cloud SQL to offer the same experience without the overhead of another SaaS tool!
But pg_branch is easy to extend with other snapshot-capable fs (it's a single trait, internally, that someone would need to implement). Happy to accept pull requests for supporting e.g. ZFS or XFS.
PostgreSQL + ext4 is uneventful, lower latency, and less wasteful of resources.
COW unlocks a ton of interesting use cases. It's easy to do on AWS Aurora but unfortunately their minimum instance size is way bigger than the regular RDS instances.
There is one more very important difference here, not only FOSS vs proprietary.
N thin clones on Aurora give you O(1) in terms of storage costs (you pay 1 time plus only for difference, which is 0 initially), but O(N) in terms of compute (N clones = N instances).
That's super expensive and prevents most people from having great DB-related test coverage in CI/CD.
(This is true for Neon's approach to pricing of branches too, if I'm not mistaken.)
But for the tech discussed here, you can run many – dozens, hundreds – clones on a single machine, having predictable budget. It's O(1) costs for both storage and compute. This unblocks dev&test activities with full-size databases for engineers in your team.
Could this work on ZFS, or a layered FS like Aufs/OverlayFS?
BTRFS is not that scary. Quota and RAID56 is broken but other features have been stable quite some time. Btrfs is used by default for few Linux distros and Facebook makes quite heavy use of it on their servers https://lwn.net/Articles/824855/
I have been running btrfs on all of my machines since 2016 as transparrent file compression helps a lot with keeping disk usage down.
Btrfs RAID1 even saved my data once when one of the SSD's decided to die suddenly.
For maximum performance you should run databases on top of XFS anyway. It also supports per-file COW via reflinks.
Perhaps I'm being overly cautious after years of not experiencing issues with ext4+LVM+LUKS. BTRFS always gave the impression of being in a perpetual state of instability, but maybe I should take another look at it.
Edit: quick google tells me APFS supports snapshots/cow, could the same approach be used here?