Site icon Softizy Blog

TokuDB Read Free Replication : not implemented in MariaDB!

TokuDB Fractal Tree

TokuDB Fractal Tree

I) Why using TokuDB?

I have been playing with TokuDB since 2013. Although it's a really good storage engine, it's sometimes full of surprises.

Initially I migrated one of my customer from InnoDB to TokuDB because it was solving all their issues : their DB has been growing to more then 1TB, and they were facing insert performances issues.

After the migration, there DB size dropped to 100GB which was really amazing, without loss in performances compared to InnoDB, and way better insert performances.

II) Read Free Replication

At this time I was using the TokuDB enterprise MariaDB 5.5.41 custom version, with Read Free Replication enabled on a slave. To enable it, you need to have row-based replication enabled on the master and to set the following variables on the slave :

tokudb_rpl_unique_checks=0
tokudb_rpl_lookup_rows=0
read-only
As a reminder, Read Free Replication allows better throughput, and reduces greatly slave lag by lowering the read IO operations. (for more informations, you can check this blog post).
In 2015, Percona acquired Tokutek, the company behind TokuDB and the TokuDB custom enterprise versions were dropped. With the recent improvement in the TokuDB engine, I decided a few weeks ago it was time to migrate the DB from TokuDB entreprise for MariaDB 5.5.41 to MariaDB 10.1.16.

The migration was really painful (this is another story), and I had a slave with data slightly different than on the master. So I was expecting a few glitch during the replication, but I wasn't expecting the replication to fail with Read Free Replication enabled.

After a few events replicated, I hit my first replication issue :

Could not execute Write_rows_v1 event on table sc_2.sc_forum_user_notification; Duplicate entry '67079-31379-7944' for key 'unq_user_parent_message_forum_topic', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.008448, end_log_pos 55965980
If Read Free Replication is enabled, why do we have a duplicate entry reported ?
After a feedback from Percona, I first thought it was an undocumented but expected behaviour. However, thanks to Tim Callaghan & Rich Prohaska comments, I discovered it was because MariaDB has never implemented (yet) the required hooks needed to have the Read Free Replication working. There's an open JIRA ticket with the needed patch to make it working properly.

III) Conclusion

If you want to rely heavily on Read Free Replication to speedup your slave, you should perhaps consider moving to Percona Server instead of MariaDB, until they implement the needed patch.

Contributors: