Commit e7f48475 authored by Rich Prohaska's avatar Rich Prohaska

DB-798 add the tokudb_rpl_check_readonly variable for RFR

parent 25c152b0
include/master-slave.inc
[connection master]
drop table if exists t;
create table t (a bigint not null, primary key(a)) engine=tokudb;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
select unix_timestamp()-@tstart <= 10;
unix_timestamp()-@tstart <= 10
1
include/diff_tables.inc [master:test.t, slave:test.t]
drop table if exists t;
include/rpl_end.inc
include/master-slave.inc
[connection master]
drop table if exists t;
create table t (a bigint not null, primary key(a)) engine=tokudb;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
select unix_timestamp()-@tstart <= 10;
unix_timestamp()-@tstart <= 10
0
include/diff_tables.inc [master:test.t, slave:test.t]
drop table if exists t;
include/rpl_end.inc
include/master-slave.inc
[connection master]
drop table if exists t;
create table t (a bigint not null, primary key(a)) engine=tokudb;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
select unix_timestamp()-@tstart <= 10;
unix_timestamp()-@tstart <= 10
1
include/diff_tables.inc [master:test.t, slave:test.t]
drop table if exists t;
include/rpl_end.inc
include/master-slave.inc
[connection master]
drop table if exists t;
create table t (a bigint not null, primary key(a)) engine=tokudb;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
select unix_timestamp()-@tstart <= 10;
unix_timestamp()-@tstart <= 10
1
include/diff_tables.inc [master:test.t, slave:test.t]
drop table if exists t;
include/rpl_end.inc
--read-only=OFF --tokudb-rpl-check-readonly=OFF --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF
# test replicated write rows log events on a table with a primary key.
# the slave is read only with tokudb unique checks disabled.
source include/have_tokudb.inc;
let $engine=tokudb;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
# initialize
connection master;
disable_warnings;
drop table if exists t;
enable_warnings;
connection slave;
# show variables like 'read_only';
# show variables like 'tokudb_rpl_unique_checks%';
# insert some rows
connection master;
# select @@binlog_format;
# select @@autocommit;
eval create table t (a bigint not null, primary key(a)) engine=$engine;
# show create table t;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
connection master;
select unix_timestamp()-@tstart <= 10;
connection slave;
# insert into t values (5); # test read-only
# show create table t;
# diff tables
connection master;
--let $diff_tables= master:test.t, slave:test.t
source include/diff_tables.inc;
# cleanup
connection master;
drop table if exists t;
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
source include/rpl_end.inc;
--read-only=OFF --tokudb-rpl-check-readonly=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF
# test replicated write rows log events on a table with a primary key.
# the slave is read only with tokudb unique checks disabled.
source include/have_tokudb.inc;
let $engine=tokudb;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
# initialize
connection master;
disable_warnings;
drop table if exists t;
enable_warnings;
connection slave;
# show variables like 'read_only';
# show variables like 'tokudb_rpl_unique_checks%';
# insert some rows
connection master;
# select @@binlog_format;
# select @@autocommit;
eval create table t (a bigint not null, primary key(a)) engine=$engine;
# show create table t;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
connection master;
select unix_timestamp()-@tstart <= 10;
connection slave;
# insert into t values (5); # test read-only
# show create table t;
# diff tables
connection master;
--let $diff_tables= master:test.t, slave:test.t
source include/diff_tables.inc;
# cleanup
connection master;
drop table if exists t;
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
source include/rpl_end.inc;
--read-only=ON --tokudb-rpl-check-readonly=OFF --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF
# test replicated write rows log events on a table with a primary key.
# the slave is read only with tokudb unique checks disabled.
source include/have_tokudb.inc;
let $engine=tokudb;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
# initialize
connection master;
disable_warnings;
drop table if exists t;
enable_warnings;
connection slave;
# show variables like 'read_only';
# show variables like 'tokudb_rpl_unique_checks%';
# insert some rows
connection master;
# select @@binlog_format;
# select @@autocommit;
eval create table t (a bigint not null, primary key(a)) engine=$engine;
# show create table t;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
connection master;
select unix_timestamp()-@tstart <= 10;
connection slave;
# insert into t values (5); # test read-only
# show create table t;
# diff tables
connection master;
--let $diff_tables= master:test.t, slave:test.t
source include/diff_tables.inc;
# cleanup
connection master;
drop table if exists t;
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
source include/rpl_end.inc;
--read-only=ON --tokudb-rpl-check-readonly=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF
# test replicated write rows log events on a table with a primary key.
# the slave is read only with tokudb unique checks disabled.
source include/have_tokudb.inc;
let $engine=tokudb;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
# initialize
connection master;
disable_warnings;
drop table if exists t;
enable_warnings;
connection slave;
# show variables like 'read_only';
# show variables like 'tokudb_rpl_unique_checks%';
# insert some rows
connection master;
# select @@binlog_format;
# select @@autocommit;
eval create table t (a bigint not null, primary key(a)) engine=$engine;
# show create table t;
select unix_timestamp() into @tstart;
insert into t values (1);
insert into t values (2),(3);
insert into t values (4);
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
connection master;
select unix_timestamp()-@tstart <= 10;
connection slave;
# insert into t values (5); # test read-only
# show create table t;
# diff tables
connection master;
--let $diff_tables= master:test.t, slave:test.t
source include/diff_tables.inc;
# cleanup
connection master;
drop table if exists t;
sync_slave_with_master;
# source include/sync_slave_sql_with_master.inc;
source include/rpl_end.inc;
...@@ -3545,8 +3545,12 @@ static void maybe_do_unique_checks_delay(THD *thd) { ...@@ -3545,8 +3545,12 @@ static void maybe_do_unique_checks_delay(THD *thd) {
} }
} }
static bool need_read_only(THD *thd) {
return opt_readonly || !THDVAR(thd, rpl_check_readonly);
}
static bool do_unique_checks(THD *thd, bool do_rpl_event) { static bool do_unique_checks(THD *thd, bool do_rpl_event) {
if (do_rpl_event && thd->slave_thread && opt_readonly && !THDVAR(thd, rpl_unique_checks)) if (do_rpl_event && thd->slave_thread && need_read_only(thd) && !THDVAR(thd, rpl_unique_checks))
return false; return false;
else else
return !thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS); return !thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS);
......
...@@ -1466,6 +1466,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1466,6 +1466,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(rpl_unique_checks_delay), MYSQL_SYSVAR(rpl_unique_checks_delay),
MYSQL_SYSVAR(rpl_lookup_rows), MYSQL_SYSVAR(rpl_lookup_rows),
MYSQL_SYSVAR(rpl_lookup_rows_delay), MYSQL_SYSVAR(rpl_lookup_rows_delay),
MYSQL_SYSVAR(rpl_check_readonly),
MYSQL_SYSVAR(optimize_index_name), MYSQL_SYSVAR(optimize_index_name),
MYSQL_SYSVAR(optimize_index_fraction), MYSQL_SYSVAR(optimize_index_fraction),
MYSQL_SYSVAR(optimize_throttle), MYSQL_SYSVAR(optimize_throttle),
......
...@@ -545,6 +545,9 @@ static MYSQL_THDVAR_BOOL(rpl_lookup_rows, PLUGIN_VAR_THDLOCAL, "lookup a row on ...@@ -545,6 +545,9 @@ static MYSQL_THDVAR_BOOL(rpl_lookup_rows, PLUGIN_VAR_THDLOCAL, "lookup a row on
static MYSQL_THDVAR_ULONGLONG(rpl_lookup_rows_delay, PLUGIN_VAR_THDLOCAL, "time in milliseconds to add to lookups on replication slave", static MYSQL_THDVAR_ULONGLONG(rpl_lookup_rows_delay, PLUGIN_VAR_THDLOCAL, "time in milliseconds to add to lookups on replication slave",
NULL, NULL, 0 /*default*/, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/); NULL, NULL, 0 /*default*/, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/);
static MYSQL_THDVAR_BOOL(rpl_check_readonly, PLUGIN_VAR_THDLOCAL, "check if the slave is read only",
NULL /*check*/, NULL /*update*/, true /*default*/);
static MYSQL_THDVAR_STR(optimize_index_name, PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC, "optimize index name (default all indexes)", NULL /*check*/, NULL /*update*/, NULL /*default*/); static MYSQL_THDVAR_STR(optimize_index_name, PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC, "optimize index name (default all indexes)", NULL /*check*/, NULL /*update*/, NULL /*default*/);
static MYSQL_THDVAR_DOUBLE(optimize_index_fraction, 0, "optimize index fraction (default 1.0 all)", NULL /*check*/, NULL /*update*/, 1.0 /*def*/, 0 /*min*/, 1.0 /*max*/, 1); static MYSQL_THDVAR_DOUBLE(optimize_index_fraction, 0, "optimize index fraction (default 1.0 all)", NULL /*check*/, NULL /*update*/, 1.0 /*def*/, 0 /*min*/, 1.0 /*max*/, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment