Exposing MyRocks internals Via system variables: Part 6, Replication
Variables and CF_OPTIONS
Let’s have a closer look at these features and the variables that apply to them.Binlog_format
Changes to the data record originate on the master and are then logged locally in the binary log. Data in the binary log is requested by the replica, which copies binary log data from the master into its own relay log and then replays the events locally. Binlog-format allows you to control the format of the binary log, allowing you to specify statement, row, or mixed based binary logging formats. For a full description of all of these binary logging formats you can check this page in the MySQL community reference . In order to use read-free replication in MyRocks, you must use the row-based binary logging format. Default: Row The default for this variable is dependent on the MySQL fork / version, but as of 5.7 the default is row. MyRocks became available in Percona Server starting with 5.7, so it’s unlikely you would have to change this variable.Rocksdb_unsafe_for_binlog
As noted above, you need to use row-based binary logging if you want to take advantage of read-free replication. But regardless of whether or not you plan to use read-free replication, you still want to avoid using statement-based binary logging given the fact that it doesn’t guarantee that data on the replicas won’t fall out of sync with the master. You can read more about this on this page of the MySQL community reference. MyRocks recognizes the dangers of using statement-based binary logging for replication and as such it leverages the variable rocksdb_unsafe_for_binlog to ensure that statement-based binary logging is not used. Default: OFF The default value ensures that statement based binary logging cannot be used. I would recommend leaving this variable at its default value.Binlog_row_image
Row-based binary logs will provide you the before and after images of the data change for the row in question. Depending on how binary logging is configured, this information can contain just the columns that changed, or all the columns in the row. This configuration is controlled by the variable binlog_row_image. For a full list of all row image options that are available you can see this page of the MySQL community reference . In order to use read-free replication in MyRocks, you must use full binlog row images. Default: fullRead_only & Super_read_only
Read-free replication works under the assumption that data on the replicas is the same as the data on the master within the transaction boundaries of the data change that is being applied via replication. This is commonly referred to as "cluster level data consistency". When working with read-free replication it’s imperative that we maintain cluster level consistency, as failure to do so can result in index level corruption as documented on this page in the MyRocks wiki . One of the easiest ways to ensure cluster level data consistency is to ensure that no writing occurs directly on your replicas. Up until version 5.7, the only way to protect your replica from direct data writes was to use the read_only system server variables which, if enabled, signaled an error to the user in the case that they attempted to make data changes on the instance. The problem with this feature is that it did not prevent data changes or signal any kind of error if the user in question had super level privileges . I’ve seen many cases where super has been granted to application accounts which wrote to replicas with the read_only variable enabled due to improper traffic routing. As soon as this happens, you’ve lost cluster level data consistency. With 5.7 a new variable called super_read_only was made available which works basically the same as read_only, but it applies to all users regardless of what privileges they have. This also has other handy features like not allowing replication changes via the change master to command. This assures that data changes will come only from replication and that users cannot accidentally change the replication status, offering the greatest level of assurance of cluster level data consistency. Default: Off (for both variables) Regardless of whether you are using MyRocks or any other storage engine in MySQL, I would highly advise that you enable both of these variables on your replicas so long as you are not using an architecture that is dependent on replica writes.Rocksdb_read_free_rpl_tables
Once the binary logs have been collected from the master and placed in the relay logs of the replica they will be replayed by the replication sql_thread. As this occurs, checks will be made against the list of tables provided in the variable rocksdb_read_free_rpl_tables to see if read-free replication should occur or not. If the table is in the list, there will be no row lookup as part of the process of replaying the row change. Default: (empty)Associated Metrics
The following instruments can be found in the performance schema:- wait/synch/rwlock/rocksdb/read_free_rpl_tables
- wait/synch/rwlock/rocksdb/skip_unique_check_tables
Conclusion
In this post, we covered the replication specific mechanics of MyRocks and the basics of how to work with read-free replication. Stay tuned for the next and final post where we’re going to cover the use cases where you’ll want to consider including MyRocks as part of your data platform as well as some final high-level considerations when implementing. In case you missed the previous posts, here they are: Part 1: Data Writing Part 2: Data Flushing Part 3: Compaction Part 4: Compression and Bloom Filters Part 5: Data ReadsOn this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Exposing MyRocks Internals Via System Variables: Part 3, Compaction
Exposing MyRocks Internals Via System Variables: Part 3, Compaction
May 7, 2019 12:00:00 AM
19
min read
Exposing MyRocks Internals via system variables: Part 4, Compression and Bloom Filters
Exposing MyRocks Internals via system variables: Part 4, Compression and Bloom Filters
May 14, 2019 12:00:00 AM
12
min read
Exposing MyRocks internals via system variables: Part 5, Data Reads
Exposing MyRocks internals via system variables: Part 5, Data Reads
May 21, 2019 12:00:00 AM
13
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.