Xaprb

Stay curious!

Blackhole tables and auto-increment keys

with 4 comments

Blackhole tables are often used on a so-called “relay slave” where some operation needs to happen but no data needs to exist. This used to have a bug that prevented AUTO_INCREMENT columns from propagating the right values through replication, but that was fixed. It turns out there’s another bug, though, that has the same effect. This one is caused when there is an INSERT into a Blackhole table, where the source data is SELECT-ed from another Blackhole table.

I think it’s wise to keep it simple. MySQL has tons of cool little features that theoretically suit edge-case uses and make ninja tricks possible, but I really trust the core plain-Jane functionality so much more than these edge-case features. That’s precisely because they often have some edge-case bugs, especially with replication.

Something that’s new to MySQL recently is Galera replication. The more I think about it, the more I think it’s fundamentally the right way to replicate. Statement-based replication was brittle; row-based is less so, but still has all kinds of gotchas. The real problem with both is that they are built into the server, not the storage engine. Engine-level replication is the way to go. PBXT has had engine-level replication for a while, although I’ve never used PBXT in production (and kudos to PostgreSQL for adding built-in replication, too). I used to want InnoDB to do replication via streaming the redo logs and applying them, but that actually has a lot of limitations. Galera is InnoDB’s answer to engine-level replication. I think Galera holds a lot of promise for the future.

Written by Xaprb

October 19th, 2011 at 5:41 pm

Posted in SQL

Tagged with , ,

4 Responses to 'Blackhole tables and auto-increment keys'

Subscribe to comments with RSS

  1. Those links are relative, and should be absolute — FYI.

    Fenway

    19 Oct 11 at 7:59 pm

  2. Fixed, thanks. This is one thing I don’t like about the new Firefox awesome bar. When I search history for a URL and copy it without loading the page, it leaves off the http:// part.

    Xaprb

    19 Oct 11 at 10:29 pm

  3. I’m writing a SQL best practices document for our devs and your statement about edge cases is applicable to my category of “don’t be slick.” I know a little bit about this bug, and I agree…this was a case of being too slick and getting bit by it. :)

    Aaron Brown

    25 Oct 11 at 8:26 pm

  4. Could you elaborate on why you think Galera replication is the right way to replicate ( I am not too familiar with Galera)? Also why the storage engine implements replication over an abstracted layer is better? Wouldn’t you loose the ability to replicate innodb to PBXT for instance?

Leave a Reply