mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
92 lines
2.3 KiB
Text
92 lines
2.3 KiB
Text
include/master-slave.inc
|
|
[connection master]
|
|
#
|
|
# Bug #25144 "replication / binlog with view breaks".
|
|
# Statements that used views didn't ensure that view were not modified
|
|
# during their execution. Indeed this led to incorrect binary log with
|
|
# statement based logging and as result to broken replication.
|
|
#
|
|
drop tables if exists t1, t2;
|
|
drop view if exists v1;
|
|
# Syncing slave with master
|
|
connection slave;
|
|
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;
|
|
# First we try to concurrently execute statement that uses view
|
|
# and statement that drops it. We use "user" locks as means to
|
|
# suspend execution of first statement once it opens our view.
|
|
select get_lock("lock_bg25144", 1);
|
|
get_lock("lock_bg25144", 1)
|
|
1
|
|
connection master1;
|
|
insert into v1 values (get_lock("lock_bg25144", 100));
|
|
connection master2;
|
|
drop view v1;
|
|
connection master;
|
|
select release_lock("lock_bg25144");
|
|
release_lock("lock_bg25144")
|
|
1
|
|
connection master1;
|
|
select release_lock("lock_bg25144");
|
|
release_lock("lock_bg25144")
|
|
1
|
|
connection master2;
|
|
connection master;
|
|
# Check that insertion through view did happen.
|
|
select * from t1;
|
|
i
|
|
1
|
|
# Syncing slave with master
|
|
connection slave;
|
|
# Check that slave was able to replicate this sequence
|
|
# which means that we got correct binlog order.
|
|
select * from t1;
|
|
i
|
|
1
|
|
connection master;
|
|
# Now we will repeat the test by trying concurrently execute
|
|
# statement that uses a view and statement that alters it.
|
|
create view v1 as select * from t1;
|
|
select get_lock("lock_bg25144", 1);
|
|
get_lock("lock_bg25144", 1)
|
|
1
|
|
connection master1;
|
|
insert into v1 values (get_lock("lock_bg25144", 100));
|
|
connection master2;
|
|
alter view v1 as select * from t2;
|
|
connection master;
|
|
select release_lock("lock_bg25144");
|
|
release_lock("lock_bg25144")
|
|
1
|
|
connection master1;
|
|
select release_lock("lock_bg25144");
|
|
release_lock("lock_bg25144")
|
|
1
|
|
connection master2;
|
|
connection master;
|
|
# Second insertion should go to t1 as well.
|
|
select * from t1;
|
|
i
|
|
1
|
|
1
|
|
select * from t2;
|
|
i
|
|
# Syncing slave with master
|
|
connection slave;
|
|
# Now let us check that statements were logged in proper order
|
|
# So we have same result on slave.
|
|
select * from t1;
|
|
i
|
|
1
|
|
1
|
|
select * from t2;
|
|
i
|
|
connection master;
|
|
drop table t1, t2;
|
|
drop view v1;
|
|
# Syncing slave with master
|
|
connection slave;
|
|
include/rpl_end.inc
|