TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

GitHub's online schema migration for MySQL

248 pointsby qiuyesuifengabout 7 years ago

15 comments

MichaelGlassabout 7 years ago
At NoRedInk, We&#x27;ve been using gh-ost for a few years now, and it&#x27;s been a pleasure.<p>- The ability to control a running migration is crucial. We have pretty predictable load, and we generally run long-running migrations during off-peak hours. If a migration runs longer than we were expecting and might run into peak hours, we can pause the migration and have the migration not impact users.<p>- hooks make it trivial to integrate with other tools. Right now it reports to slack, but if we used it more, we&#x27;d likely hook it up to real monitoring infrastructure.<p>- there&#x27;s a lot of default behavior that we want. I&#x27;d recommend regular users wrap their best practices in another script and not call gh-ost directly. It&#x27;s nice to not worry about good defaults for e.g. throttling, or worrying about whether ghost is hooked up to some kind of external monitoring.
评论 #16984049 未加载
perlgeekabout 7 years ago
We evaluated gh-ost, but the killer for us is that it doesn&#x27;t support any kind of foreign keys.<p>I understand that at GitHub&#x27;s scale, foreign keys might be more of a hassle than what they are worth, but for a smallish company that values data integrity over scale and uptime, this is not an acceptable choice.
评论 #16983784 未加载
评论 #16983847 未加载
评论 #16983630 未加载
评论 #16986503 未加载
评论 #16984495 未加载
throwawayplsabout 7 years ago
Back when I worked for Shopify, I got a chance to work on something similar -- GhostFerry(<a href="https:&#x2F;&#x2F;github.com&#x2F;shopify&#x2F;ghostferry" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shopify&#x2F;ghostferry</a>), which allows for doing all sorts of migrations, that too between various databases.<p>It was recently open-sourced. Do take a look.
评论 #16983621 未加载
viraptorabout 7 years ago
I used it and it&#x27;s really impressive. Works as described. The only issue with this is that you can&#x27;t easily use it without understanding how it works. It&#x27;s more of a system you have to own rather than a tool you can use, so you can&#x27;t just point a new person at it and go &quot;just run this&quot;.
评论 #16983136 未加载
analogmemoryabout 7 years ago
So my understanding is that this is for migrating a db to a new one? Can someone explain like I was beginner why&#x2F;how&#x27;d you would use this?
评论 #16983489 未加载
Existenceblinksabout 7 years ago
That&#x27;s really old and still good strategy. [off-topic] I&#x27;ve heard this first time from a novel (1964).<p>Flynn.io uses the same kind of strategy; transaction log &amp;&amp; async replication (<a href="https:&#x2F;&#x2F;flynn.io&#x2F;docs&#x2F;databases" rel="nofollow">https:&#x2F;&#x2F;flynn.io&#x2F;docs&#x2F;databases</a>)<p>A little sad nanobox.io which one of my app running on has an inferior strategy; temporarily offline at the last sync moment (<a href="https:&#x2F;&#x2F;docs.nanobox.io&#x2F;data-management&#x2F;data-migrations-scaling&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.nanobox.io&#x2F;data-management&#x2F;data-migrations-scal...</a>)
AdamJacobMullerabout 7 years ago
This is a really amazing, very well designed and thought out, tool that solves a problem that should never exist.
pkulakabout 7 years ago
Holy crap, an alternative to Percona? Why does MySQL get two awesome tools and Postgres nothing?
评论 #16983275 未加载
评论 #16984054 未加载
评论 #16983268 未加载
评论 #16983187 未加载
thathooabout 7 years ago
Square also its online schema migration tool that is open source here: <a href="https:&#x2F;&#x2F;github.com&#x2F;square&#x2F;shift" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;square&#x2F;shift</a><p>Its pretty cool. Check it out as well.
评论 #16987598 未加载
ceohockey60about 7 years ago
Very cool! Curious, does this leverage this go-mysql library at all? <a href="https:&#x2F;&#x2F;github.com&#x2F;siddontang&#x2F;go-mysql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;siddontang&#x2F;go-mysql</a>
评论 #16983188 未加载
kd22about 7 years ago
Can someone shed some light on how this tool compares to something like Flyway?
评论 #16986606 未加载
magoonabout 7 years ago
I believe RDS uses this same technique for instance resize&#x2F;replace.
zmoazeniabout 7 years ago
We use gh-ost at Harvest[1] and it&#x27;s a dream in comparison to manually migrating on a replica and switching master&#x2F;slave roles [2].<p>Also the linked post[3] in the readme hit us very close to home. We originally tried some of our migrations with pt-online-schema-change, which was great in theory but caused a lot of locking contention during the actual process.<p>I see many people hammering on the lack of foreign key support which is interesting to me. At some point, a database system grows to where relying on MySQL&#x27;s Online DDL[4] &quot;works&quot; but not really with production load. I feel like a team knows when they need to bring in a tool like this.<p>The dev in me understands how wonderful FKs are for consistency. But the db-guy in me that has had to deal with locking issues recognizes FKs as a tradeoff, not dogma.<p>If you shy away from migrating your large or busy tables, or are scheduling frequent maintenance down times in order to migrate these tables, that&#x27;s when gh-ost (and others) are appropriate to evaluate.<p>So for us it&#x27;s not an immediate red flag that gh-ost doesn&#x27;t support FKs. We just have to work around that limitation[5] because the alternatives are much worse.<p>For the record, we don&#x27;t gh-ost all of our migrations. Only the ones that are deemed sufficiently large enough are gh-osted and those heuristics will change from team-to-team.<p>But as a guy who has had to deal with our database issues AND as a developer who doesn&#x27;t want to be chained by a database design decision from a decade ago, I love the flexibility gh-ost gives us as we continue to grow.<p>[1] <a href="https:&#x2F;&#x2F;www.getharvest.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.getharvest.com&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;replication-features-differing-tables.html" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;replication-features...</a><p>[3] <a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;replication-features-differing-tables.html" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;replication-features...</a><p>[4] <a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;innodb-create-index-overview.html" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.6&#x2F;en&#x2F;innodb-create-index-...</a><p>[5] <a href="https:&#x2F;&#x2F;github.com&#x2F;github&#x2F;gh-ost&#x2F;issues&#x2F;507#issuecomment-338725563" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;github&#x2F;gh-ost&#x2F;issues&#x2F;507#issuecomment-338...</a>
z3t4about 7 years ago
I was investigating using the binary log for another project a few years ago, but came to the conclusion that it&#x27;s too hard to work with ... I don&#x27;t remember any details though, maybe someone can fill me in ?
qaqabout 7 years ago
You can jump through hoops or just use an RDBMS that supports transactional DDL.
评论 #16983766 未加载
评论 #16983474 未加载
评论 #16983498 未加载