Skip to content
Permalink
Browse files
Cleanups
- Remove not used thd_rpl_is_parallel()
- Remove not used mysql_notify_thread_having_shared_lock()
- Remove not needed LOCK_thread_count from MYSQL_BIN_LOG::reset_logs()
  - LOCK_thread_count is not protecting against rollback, so this
    code and comment is not needed
- Remove mutex_locks in slave.cc that are not needed.
  Added THD::assert_not_linked() to ensure that it was safe to remove
- Fixed not repeatable test load_data_stmt_view
- Updated binlog_killed to test removal of mutex
  (thanks to Andrei Elkin for test)
- More code comments
  • Loading branch information
montywi committed Dec 8, 2017
1 parent 6d63a03 commit c458173
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 109 deletions.
@@ -649,7 +649,6 @@ void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
void thd_storage_lock_wait(MYSQL_THD thd, long long value);
int thd_tx_isolation(const MYSQL_THD thd);
int thd_tx_is_read_only(const MYSQL_THD thd);
int thd_rpl_is_parallel(const MYSQL_THD thd);
/**
Create a temporary file.
@@ -518,7 +518,6 @@
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -518,7 +518,6 @@
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -518,7 +518,6 @@
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -472,7 +472,6 @@
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -518,7 +518,6 @@
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -179,6 +179,97 @@ RELEASE_LOCK("a")
1
drop table t4;
drop function bug27563;
FLUSH LOGS;
connect con3, localhost, root,,;
connection con3;
MI: MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
master-bin.000002 # Gtid_list # # [#-#-#]
master-bin.000002 # Binlog_checkpoint # # master-bin.000001
master-bin.000002 # Binlog_checkpoint # # master-bin.000002
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=3
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IM: INNODB, MyISAM
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IMI: INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
MI2: MyISAM, INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=8
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Intvar # # INSERT_ID=9
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # ROLLBACK
connection default;
disconnect con1;
disconnect con2;
@@ -1,3 +1,4 @@
reset master;
create table t1 (i int, j int);
create view v1 as select i from t1;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/3940.data' INTO TABLE v1 (i);
@@ -349,6 +349,87 @@ drop table t4;
drop function bug27563;


# Prove that killing connection in the middle
# of mixed engine transactions affect binlogging
# as specified.

# keep binlogging for this piece of test in a new file
FLUSH LOGS;

# Connection con3 as transaction generator thoughout the test
connect (con3, localhost, root,,);

connection con3;
let $ID= `select connection_id()`;

--echo MI: MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);

#Connection con1 as killer throughout the test
connection con1;
--replace_result $ID ID
--eval KILL $ID
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--let $binlog_start= 4
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)

disconnect con3;
connect (con3, localhost, root,,);
connection con3;
let $ID= `select connection_id()`;

--echo IM: INNODB, MyISAM
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);

connection con1;
--replace_result $ID ID
--eval KILL $ID
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)

disconnect con3;
connect (con3, localhost, root,,);
connection con3;
let $ID= `select connection_id()`;

--echo IMI: INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);

connection con1;
--replace_result $ID ID
--eval KILL $ID
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)

disconnect con3;
connect (con3, localhost, root,,);
connection con3;
let $ID= `select connection_id()`;

--echo MI2: MyISAM, INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);

connection con1;
--replace_result $ID ID
--eval KILL $ID
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc


#
# common cleanup
#
@@ -8,13 +8,17 @@
1
EOF

reset master;

create table t1 (i int, j int);
create view v1 as select i from t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/3940.data' INTO TABLE v1 (i)
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/3940.data' INTO TABLE v1
select * from v1;
--let $binlog_file = LAST
--source include/show_binlog_events.inc
drop view v1;
drop table t1;
--remove_file $MYSQLTEST_VARDIR/3940.data
@@ -4171,14 +4171,6 @@ bool MYSQL_BIN_LOG::reset_logs(THD *thd, bool create_new_log,
mysql_mutex_unlock(&LOCK_xid_list);
}

/*
The following mutex is needed to ensure that no threads call
'delete thd' as we would then risk missing a 'rollback' from this
thread. If the transaction involved MyISAM tables, it should go
into binlog even on rollback.
*/
mysql_mutex_lock(&LOCK_thread_count);

/* Save variables so that we can reopen the log */
save_name=name;
name=0; // Protect against free
@@ -4285,7 +4277,6 @@ bool MYSQL_BIN_LOG::reset_logs(THD *thd, bool create_new_log,
err:
if (error == 1)
name= const_cast<char*>(save_name);
mysql_mutex_unlock(&LOCK_thread_count);

if (!is_relay_log)
{
@@ -4967,9 +4967,7 @@ log space");
// TODO: make rpl_status part of Master_info
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);

mysql_mutex_lock(&LOCK_thread_count);
thd->unlink();
mysql_mutex_unlock(&LOCK_thread_count);
thd->assert_not_linked();
delete thd;
thread_safe_decrement32(&service_thread_count);
signal_thd_deleted();
@@ -5648,11 +5646,7 @@ pthread_handler_t handle_slave_sql(void *arg)

rpl_parallel_resize_pool_if_no_slaves();

/* TODO: Check if this lock is needed */
mysql_mutex_lock(&LOCK_thread_count);
delete serial_rgi;
mysql_mutex_unlock(&LOCK_thread_count);

delete thd;
thread_safe_decrement32(&service_thread_count);
signal_thd_deleted();

0 comments on commit c458173

Please sign in to comment.