2009-11-30 19:21:40 +03:00
|
|
|
#
|
|
|
|
# This file contains test cases for bugs which involve views, several
|
|
|
|
# concurren connections and manifest themselves as wrong binary log
|
|
|
|
# sequence which results in broken replication. In principle we are
|
|
|
|
# mostly interested in SBR here but this test will also work with RBR.
|
|
|
|
#
|
|
|
|
--source include/master-slave.inc
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug #25144 "replication / binlog with view breaks".
|
|
|
|
--echo # Statements that used views didn't ensure that view were not modified
|
|
|
|
--echo # during their execution. Indeed this led to incorrect binary log with
|
|
|
|
--echo # statement based logging and as result to broken replication.
|
|
|
|
--echo #
|
2010-02-05 18:05:13 +03:00
|
|
|
#
|
|
|
|
# Suppress "unsafe" warnings.
|
|
|
|
#
|
|
|
|
disable_query_log;
|
2010-04-28 14:47:49 +02:00
|
|
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
2010-02-05 18:05:13 +03:00
|
|
|
enable_query_log;
|
|
|
|
|
2009-11-30 19:21:40 +03:00
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop tables if exists t1, t2;
|
|
|
|
drop view if exists v1;
|
|
|
|
--enable_warnings
|
2016-03-25 20:51:22 +04:00
|
|
|
--echo # Syncing slave with master
|
2009-11-30 19:21:40 +03:00
|
|
|
--sync_slave_with_master
|
|
|
|
|
|
|
|
connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
create table t1 (i int);
|
|
|
|
create table t2 (i int);
|
|
|
|
create view v1 as select * from t1;
|
|
|
|
|
|
|
|
--echo # First we try to concurrently execute statement that uses view
|
|
|
|
--echo # and statement that drops it. We use "user" locks as means to
|
|
|
|
--echo # suspend execution of first statement once it opens our view.
|
|
|
|
select get_lock("lock_bg25144", 1);
|
|
|
|
|
|
|
|
connection master1;
|
|
|
|
--send insert into v1 values (get_lock("lock_bg25144", 100))
|
|
|
|
|
|
|
|
connection master2;
|
|
|
|
let $wait_condition=
|
|
|
|
select count(*) = 1 from information_schema.processlist
|
|
|
|
where state = "User lock" and info like "insert into v1 %lock_bg25144%";
|
|
|
|
--source include/wait_condition.inc
|
|
|
|
--send drop view v1
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
let $wait_condition=
|
|
|
|
select count(*) = 1 from information_schema.processlist
|
Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and
FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
Also replaced "Table lock" thread state name, which was used
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
more consistent with other thread state names.
Updated test cases and their results according to these
changes.
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
mysql-test/r/query_cache.result:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/t/query_cache.test:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysys/thr_lock.c:
Replaced "Table lock" thread state name, which was used by
threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
consistent with thread state names which are used while
waiting for metadata locks and table flush.
sql/mdl.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/mdl.h:
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/sql_base.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for table flush, with a more elaborate
"Waiting for table flush".
2010-08-06 15:29:37 +04:00
|
|
|
where state = "Waiting for table metadata lock" and info = "drop view v1";
|
2009-11-30 19:21:40 +03:00
|
|
|
--source include/wait_condition.inc
|
|
|
|
|
|
|
|
select release_lock("lock_bg25144");
|
|
|
|
|
|
|
|
connection master1;
|
2010-02-02 16:58:15 +03:00
|
|
|
--disable_warnings
|
2009-11-30 19:21:40 +03:00
|
|
|
--reap
|
2010-02-02 16:58:15 +03:00
|
|
|
--enable_warnings
|
2009-11-30 19:21:40 +03:00
|
|
|
select release_lock("lock_bg25144");
|
|
|
|
|
|
|
|
connection master2;
|
|
|
|
--reap
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
--echo # Check that insertion through view did happen.
|
|
|
|
select * from t1;
|
2016-03-25 20:51:22 +04:00
|
|
|
--echo # Syncing slave with master
|
2009-11-30 19:21:40 +03:00
|
|
|
--sync_slave_with_master
|
|
|
|
--echo # Check that slave was able to replicate this sequence
|
|
|
|
--echo # which means that we got correct binlog order.
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
--echo # Now we will repeat the test by trying concurrently execute
|
|
|
|
--echo # statement that uses a view and statement that alters it.
|
|
|
|
create view v1 as select * from t1;
|
|
|
|
|
|
|
|
select get_lock("lock_bg25144", 1);
|
|
|
|
|
|
|
|
connection master1;
|
|
|
|
--send insert into v1 values (get_lock("lock_bg25144", 100))
|
|
|
|
|
|
|
|
connection master2;
|
|
|
|
let $wait_condition=
|
|
|
|
select count(*) = 1 from information_schema.processlist
|
|
|
|
where state = "User lock" and info like "insert into v1 %lock_bg25144%";
|
|
|
|
--source include/wait_condition.inc
|
|
|
|
--send alter view v1 as select * from t2
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
let $wait_condition=
|
|
|
|
select count(*) = 1 from information_schema.processlist
|
Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and
FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
Also replaced "Table lock" thread state name, which was used
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
more consistent with other thread state names.
Updated test cases and their results according to these
changes.
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
mysql-test/r/query_cache.result:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/t/query_cache.test:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysys/thr_lock.c:
Replaced "Table lock" thread state name, which was used by
threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
consistent with thread state names which are used while
waiting for metadata locks and table flush.
sql/mdl.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/mdl.h:
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/sql_base.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for table flush, with a more elaborate
"Waiting for table flush".
2010-08-06 15:29:37 +04:00
|
|
|
where state = "Waiting for table metadata lock" and
|
2009-11-30 19:21:40 +03:00
|
|
|
info = "alter view v1 as select * from t2";
|
|
|
|
--source include/wait_condition.inc
|
|
|
|
|
|
|
|
select release_lock("lock_bg25144");
|
|
|
|
|
|
|
|
connection master1;
|
2010-02-02 16:58:15 +03:00
|
|
|
--disable_warnings
|
2009-11-30 19:21:40 +03:00
|
|
|
--reap
|
2010-02-02 16:58:15 +03:00
|
|
|
--enable_warnings
|
2009-11-30 19:21:40 +03:00
|
|
|
select release_lock("lock_bg25144");
|
|
|
|
|
|
|
|
connection master2;
|
|
|
|
--reap
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
|
|
|
|
--echo # Second insertion should go to t1 as well.
|
|
|
|
select * from t1;
|
|
|
|
select * from t2;
|
|
|
|
|
2016-03-25 20:51:22 +04:00
|
|
|
--echo # Syncing slave with master
|
2009-11-30 19:21:40 +03:00
|
|
|
--sync_slave_with_master
|
|
|
|
--echo # Now let us check that statements were logged in proper order
|
|
|
|
--echo # So we have same result on slave.
|
|
|
|
select * from t1;
|
|
|
|
select * from t2;
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
drop table t1, t2;
|
|
|
|
drop view v1;
|
2016-03-25 20:51:22 +04:00
|
|
|
--echo # Syncing slave with master
|
2009-11-30 19:21:40 +03:00
|
|
|
--sync_slave_with_master
|
2010-12-19 18:15:12 +01:00
|
|
|
--source include/rpl_end.inc
|