Read Free Replication特性
MyRocks具有一个名为“Read Free Replication”的功能,可显着提高复制性能。 此功能的灵感来自TokuDB。此外还有一个名为“Skip Unique Checking”的功能。
Read Free Replication意味着在UPDATE或DELETE期间不是从数据库中读取旧数据,而是使用binlog中的信息并跳过此步骤。 跳过唯一检查意味着我们可以禁用正在进行的检查,以确保在INSERT或UPDATE期间不存在PRIMARY或UNIQUE键。 这两个功能都可以提高性能,但也存在一些潜在的问题。
控制这些的设置如下:
* rocksdb-read-free-rpl-tables = <list_of_tables> - 为指定的表列表启用“读取自由复制”。此功能需要基于行的二进制日志记录。 master上的binlog_row_image选项必须为FULL。* rocksdb_skip_unique_check_tables = <list_of_tables> - 这允许在复制滞后时跳过唯一键检查,并与unique_check_lag_threshold/unique_check_lag_reset_threshold 一起使用。设置这些值并且从站上的延迟足够高时,系统将停止对指定表执行唯一键检查。
1、辅助索引一些行丢失
create table t (id int primary key, i1 int, i2 int, value int, index (i1), index (i2)) engine=rocksdb;insert into t values (1,1,1,1),(2,2,2,2),(3,3,3,3);s:delete from t where id <= 2;m:update t set i2=100, value=100 where id=1;s:mysql> select count(*) from t force index(primary);+----------+| count(*) |+----------+| 2 |+----------+1 row in set (0.00 sec)mysql> select count(*) from t force index(i1);+----------+| count(*) |+----------+| 1 |+----------+1 row in set (0.00 sec)mysql> select count(*) from t force index(i2);+----------+| count(*) |+----------+| 2 |+----------+1 row in set (0.00 sec)mysql> select * from t where id=1;+----+------+------+-------+| id | i1 | i2 | value |+----+------+------+-------+| 1 | 1 | 100 | 100 |+----+------+------+-------+1 row in set (0.00 sec)mysql> select i1 from t where i1=1;Empty set (0.00 sec)mysql> select i2 from t where i2=100;+------+| i2 |+------+| 100 |+------+1 row in set (0.00 sec)
2、辅助索引有额外的行
M:create table t (id int primary key, i1 int, i2 int, value int, index (i1), index (i2)) engine=rocksdb;insert into t values (1,1,1,1),(2,2,2,2),(3,3,3,3);S:update t set i1=100 where id=1;M:delete from t where id=1;S:mysql> select count(*) from t force index(primary);+----------+| count(*) |+----------+| 2 |+----------+1 row in set (0.00 sec)mysql> select count(*) from t force index(i1);+----------+| count(*) |+----------+| 3 |+----------+1 row in set (0.00 sec)mysql> select count(*) from t force index(i2);+----------+| count(*) |+----------+| 2 |+----------+1 row in set (0.00 sec)mysql> select i1 from t where i1=100;+------+| i1 |+------+| 100 |+------+1 row in set (0.00 sec)
MyRocks支持一个类似的mysql系统变量’unique_checks’,我觉得有些用户很有用。 禁用此会话变量(设置unique_checks = OFF)将禁用给定会话的唯一检查。 此系统变量也通过复制流传播,这意味着从属设备也将跳过唯一检查,这可以减少批量加载等大型事务的复制延迟。 与Read Free Replication类似,如果从站上不允许进行其他修改,则使用Skip Unique Checks对从站应该是安全的。 如果从站上允许更改(复制除外),则可能会在从站上获取不正确的数据。建议不要在主服务器上启用“跳过唯一检查”,除非您100%确定已插入的数据尚不存在。
