gh-ost
reshape
Our great sponsors
gh-ost | reshape | |
---|---|---|
32 | 16 | |
11,934 | 1,598 | |
1.0% | - | |
7.4 | 7.4 | |
3 days ago | 11 days ago | |
Go | Rust | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
gh-ost
-
How Modern SQL Databases Are Changing Web Development - #3 Better Developer Experience
I’ve been through multiple incidents where everything worked fine in the testing environment but ended up locking the production database for minutes when deployed. A category of open-source tools called OSC (Online Schema Change) exists to mitigate such pain, like gh-ost used by GitHub and OSC used by Meta. They work by creating a set of "ghost tables" to apply the migrations, copy over old data from the original tables, and catch up with new writes simultaneously. When all old data is migrated, you can trigger a cutover to make the "ghost tables" production. Check the post below for a great introduction and comparison:
-
We migrated to SQL. Our biggest learning? Don't use Prisma
Sounds like it's basically explained in the gh-ost readme https://github.com/github/gh-ost#how
I think it amounts to "use views to decouple access to the table with a fixed interface" and "use triggers for migrating data between tables"
-
Ask HN: Is PostgreSQL better than MySQL?
Gh-ost is the new hotness. Simple to use and lots of great features: https://github.com/github/gh-ost
-
Changing column from longtext to mediumtext taking over 2 hours
As they have said it depends on the size of the table on disk and the number of rows, but an alter in production is not difficult to last from seconds to days. I don't know if you are doing the alter as is but try to check https://docs.percona.com/percona-toolkit/pt-online-schema-change.html or https://github.com/github/gh-ost , they usually simplify a lot the alters.
Not sure which version of MySQL you're using, but one approach would be to use a tool like pt-online-schema-change (from Percona) or g-host -- which will create a duplicate table and then swap it in place of the original table. It's a safer approach when operating in production environments. Here's a good comparison of the tools many people use https://planetscale.com/docs/learn/online-schema-change-tools-comparison
-
Changing Tires at 100mph: A Guide to Zero Downtime Migrations
Actually I never tried but I was scared by the small print of GH not using RDS themselves [1] and Ghost relying on lower-level features that might be not easily available in RDS. Also I had the impression you have to setup a normal non-RDS replica attached to your RDS master?
MySQL has some robust tooling in this space. Some of the tools use triggers to copy to a new table. GitHub's gh-ost[1] is probably the state of the art, and uses the binary log stream to replicate the data.
-
How Retool upgraded its 4 TB main application PostgreSQL database
https://github.com/github/gh-ost/issues/331#issuecomment-266...) it does become a little bit of a "you do not have google problems" type discussion.
(Perhaps you do have such problems, I don't know where you work! But 99%+ of companies don't have such problems and never will.)
-
We lost 54k GitHub stars
GitHub doesn't use foreign keys[1], and there's likely many tables related to all the users, notifications, permissions, etc... that would need to be cleaned up. Without foreign keys they likely have some system process that does this instead of a simple `DELETE FROM` which cascades.
1. https://github.com/github/gh-ost/issues/331#issuecomment-266...
reshape
-
Pgroll: zero-downtime, undoable, schema migrations for Postgres
Cool stuff! Do you have any thoughts about how this compares to https://github.com/fabianlindfors/reshape?
-
Postgres schema changes are still a PITA
From what I know, there is only one project that tries something close to this: the relatively recent Reshape. It uses Postgres views to expose the two versions of the schema and triggers to upgrade/downgrade the new data. It doesn’t do the constraints part as described above, but shows that this approach is possible. Combined with the Xata pull request based workflow, I think the ideal system described above is possible!
-
Conceptually how do you handle deploys of SQL related things (table definition, scripts, stored procs etc) in a CI/CD way?
My idea is not unique. Reshape is similar, but bigger in scope.
Shameless plug: I’ve been working on a tool called Reshape in this space: https://github.com/fabianlindfors/reshape. It fully automates zero-downtime schema migrations and avoids all the manual work that has been discussed in the comments here.
-
Changing Tires at 100mph: A Guide to Zero Downtime Migrations
Anybody interested in this subject might also be interested in a tool for Postgres I’ve been working on, Reshape: https://github.com/fabianlindfors/reshape. It aims to fully automate away all the pain and manual steps zero-downtime migrations normally requires :)
-
PostgreSQL at Scale: Database Schema Changes Without Downtime
This post is absolutely terrific and has been been my main reference for Reshape, an automated, zero-downtime schema migration tool: https://github.com/fabianlindfors/reshape
- When Postgres blocks: tips for dealing with locks
-
Atlas – Terraform but for Database Migrations
I thought the established wisdom is to make schema migration compatible with both the old app and the new app, whenever it is possible? E.g. you can safely add a nullable column, and it shouldn't trip up the old app nor the new app, unless you are using some crappy ORM that does "SELECT *", or you are on an older MySQL version that may take hours/days/weeks to rewrite the whole table just to add a nullable column.
https://github.com/fabianlindfors/reshape, on HN front page a couple weeks ago, has some nice tricks to help with the incompatible cases.
-
Why I Enjoy PostgreSQL – Infrastructure Engineer's Perspective
Great article! For anybody interested in this topic, I've been working on a schema migration tool which automates zero-downtime migrations using many of the techniques mentioned: https://github.com/fabianlindfors/reshape. It also uses some other incredible Postgres features, like updatable views and schemas.
It was discussed here on HN about a week back: https://news.ycombinator.com/item?id=29825520
-
Zero-downtime schema migrations in Postgres using Reshape
> We have migrated a few fields from varchar to integer. How would your solution deal with this
There is actually an example in the README on how to change a column from TEXT to INTEGER, the technique would be the same the other way around: https://github.com/fabianlindfors/reshape#alter-column
For the cases that require manual handling, that is a bit tricky. I'm not sure Reshape would be able to automate that in any meaningful way so the best thing might just be to fall back to a standard procedure of making the changes in two separate migrations, where the manual changes are done in between.
> Another one is adding foreign keys where the existing data does not conform to the foreign key constraint.
I have given this some thought before as I wanted to add a migration which can add new foreign keys. I think it can be done by writing some migrations first which update the existing data to conform to the constraint, for example adding missing values. This can be done with `alter_column` right now and there will be more comprehensive migrations for data changes in the future.
What are some alternatives?
pg-online-schema-change - Easy CLI tool for making zero downtime schema changes and backfills in PostgreSQL [Moved to: https://github.com/shayonj/pg-osc]
doctrine-test-bundle - Symfony bundle to isolate your app's doctrine database tests and improve the test performance
squawk - 🐘 linter for PostgreSQL, focused on migrations
pgroll - PostgreSQL zero-downtime migrations made easy
migra - Like diff but for PostgreSQL schemas
pg_squeeze - A PostgreSQL extension for automatic bloat cleanup
hub - A command-line tool that makes git easier to use with GitHub.
Jenkins - Jenkins automation server
gormigrate - Minimalistic database migration helper for Gorm ORM
atlas - A modern tool for managing database schemas
Large Hadron Migrator - Online MySQL schema migrations