Massively Parallel Postgres Backups
82 points by ksec 4 days ago | 9 comments
Onavo 3 hours ago
Interesting, last I checked PlanetScale still doesn't have in place Postgres version updates.
replybddicken 2 hours ago
Broadly for Pg, minor version upgrades are straightforward as the data on disk is guaranteed to be compatible. All it takes is a restart or switchover to upgrade.
replyMajor versions are more challenging for "vanilla" Postgres because that's not the case. Storage/catalog formats may change. There needs to be an explicit upgrade process for the data (eg, a database created with v18 won't work out of the box with v19).
The cool thing is, software like Neki (and Vitess for MySQL, which we maintain) have architectures that lend themselves to making this much more feasible. Because the actual database nodes sit behind a router + parser layer with Pg/MySQL compatibility, the upgrades can be done transparently to the user. We plan to write more about how this works in the future.
CodesInChaos 2 hours ago
I believe most major versions of postgres only change metadata, so the downtime only scales with the size of the schema (usually small) and not the size of the data.
reply
The broader takeaway is the principle of, "how do I take something that doesn't scale on its own and make it so?" This applies to backups, compute, storage layers, proxies. It's why Neki and Vitess are so powerful for everything from small 1GB databases to petabytes.
Hanging around to answer questions, too :)
When doing the last streaming of the wal from the primary the article mentions that the nodes will catch up to replication time `T`.
How do the nodes coordinate this time `T`? Is it simply just choosing a time in the future (after the backup has started) and waiting till they all catch up or is there more realtime coordination happening?
Also, in another part it's mentioned that "Time T is saved to ensure we know the precise time, down to the second, included in this backup." My question is that if 1 second is granular enough? I'm assuming that this is a simplification for the sake of explanation and Time T is a timestamp with at least millisecond granularity. I regularly play with otel data that can have nano-second granularity so I'm assuming is millisecond or more
with that said you can restore without PITR if you don't care about synchronization, but generally you'll just use PITR
I know that Citus has a `citus_create_restore_point()` (or so) function that, when called, guarantees that no 2PC commits are in flight and creates a WAL restore point in every shard. Therefore, restoring shards to that point will leave the DB in a consistent state. Do you do something similar?