Skip to content

Commit 15f46d5

Browse files
committed
MDEV-7409 On RBR, extend the PROCESSLIST info to include at least the name of the recently used table
When RBR is used, add the db name to db Field and table name to Status Field of the "SHOW FULL PROCESSLIST" command for SQL thread.
1 parent b7b4c33 commit 15f46d5

File tree

3 files changed

+204
-20
lines changed

3 files changed

+204
-20
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
include/master-slave.inc
2+
[connection master]
3+
connection master;
4+
create table t1(a int primary key);
5+
connection slave;
6+
SET GLOBAL debug_dbug="+d,should_sleep_for_mdev7409";
7+
select * from t1;
8+
a
9+
connection master;
10+
insert into t1(a) values(1);
11+
#monitoring write rows
12+
connection slave;
13+
SELECT db , state FROM INFORMATION_SCHEMA.PROCESSLIST
14+
WHERE DB = 'test' AND STATE LIKE "Write_rows_log_event::write_row(%) on table t1";
15+
db state
16+
test Write_rows_log_event::write_row(-1) on table t1
17+
#monitoring update rows
18+
connection master;
19+
update t1 set a = a + 4194304 ;
20+
connection slave;
21+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
22+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::find_row(%) on table t1";
23+
db state
24+
test Update_rows_log_event::find_row(-1) on table t1
25+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
26+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::unpack_current_row(%) on table t1";
27+
db state
28+
test Update_rows_log_event::unpack_current_row(-1) on table t1
29+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
30+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::ha_update_row(%) on table t1";
31+
db state
32+
test Update_rows_log_event::ha_update_row(-1) on table t1
33+
#monitoring delete rows
34+
connection master;
35+
delete from t1 where a>1;
36+
connection slave;
37+
SELECT db , state FROM INFORMATION_SCHEMA.PROCESSLIST
38+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::find_row(%) on table t1";
39+
db state
40+
test Delete_rows_log_event::find_row(-1) on table t1
41+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
42+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::ha_delete_row(%) on table t1";
43+
db state
44+
test Delete_rows_log_event::ha_delete_row(-1) on table t1
45+
connection master;
46+
drop table t1;
47+
connection slave;
48+
SET GLOBAL debug_dbug="";
49+
include/rpl_end.inc
50+
connection server_2;
51+
connection server_2;
52+
connection server_2;
53+
connection server_2;
54+
connection server_1;
55+
connection server_1;
56+
connection server_1;
57+
connection server_2;
58+
connection server_1;
59+
connection server_2;
60+
connection server_2;
61+
connection server_1;
62+
connection server_1;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
--source include/have_innodb.inc
2+
--source include/have_binlog_format_row.inc
3+
--source include/master-slave.inc
4+
--enable_connect_log
5+
6+
--connection master
7+
create table t1(a int primary key);
8+
--save_master_pos
9+
10+
--connection slave
11+
--sync_with_master
12+
SET GLOBAL debug_dbug="+d,should_sleep_for_mdev7409";
13+
select * from t1;
14+
15+
--connection master
16+
insert into t1(a) values(1);
17+
--save_master_pos
18+
19+
--echo #monitoring write rows
20+
--connection slave
21+
22+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
23+
WHERE DB = 'test' AND STATE LIKE "Write_rows_log_event::write_row(%) on table t1";
24+
--source include/wait_condition.inc
25+
SELECT db , state FROM INFORMATION_SCHEMA.PROCESSLIST
26+
WHERE DB = 'test' AND STATE LIKE "Write_rows_log_event::write_row(%) on table t1";
27+
--sync_with_master
28+
29+
--echo #monitoring update rows
30+
--connection master
31+
update t1 set a = a + 4194304 ;
32+
33+
--connection slave
34+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
35+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::find_row(%) on table t1";
36+
--source include/wait_condition.inc
37+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
38+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::find_row(%) on table t1";
39+
40+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
41+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::unpack_current_row(%) on table t1";
42+
--source include/wait_condition.inc
43+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
44+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::unpack_current_row(%) on table t1";
45+
46+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
47+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::ha_update_row(%) on table t1";
48+
--source include/wait_condition.inc
49+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
50+
WHERE DB = 'test' AND STATE LIKE "Update_rows_log_event::ha_update_row(%) on table t1";
51+
52+
--source include/wait_condition.inc
53+
--sync_with_master
54+
55+
--echo #monitoring delete rows
56+
--connection master
57+
delete from t1 where a>1;
58+
59+
--connection slave
60+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
61+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::find_row(%) on table t1";
62+
--source include/wait_condition.inc
63+
SELECT db , state FROM INFORMATION_SCHEMA.PROCESSLIST
64+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::find_row(%) on table t1";
65+
66+
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
67+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::ha_delete_row(%) on table t1";
68+
--source include/wait_condition.inc
69+
SELECT db, state FROM INFORMATION_SCHEMA.PROCESSLIST
70+
WHERE DB = 'test' AND STATE LIKE "Delete_rows_log_event::ha_delete_row(%) on table t1";
71+
72+
--sync_with_master
73+
74+
#CleanUp
75+
--connection master
76+
drop table t1;
77+
--connection slave
78+
SET GLOBAL debug_dbug="";
79+
--source include/rpl_end.inc

sql/log_event.cc

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11765,18 +11765,27 @@ Write_rows_log_event::do_exec_row(rpl_group_info *rgi)
1176511765
{
1176611766
DBUG_ASSERT(m_table != NULL);
1176711767
const char *tmp= thd->get_proc_info();
11768-
const char *message= "Write_rows_log_event::write_row()";
11768+
char *tmp_db= thd->db;
11769+
char *message, msg[128];
11770+
my_snprintf(msg, sizeof(msg),"Write_rows_log_event::write_row() on table %s",
11771+
m_table->s->table_name.str);
11772+
thd->db= m_table->s->db.str;
11773+
message= msg;
1176911774

1177011775
#ifdef WSREP_PROC_INFO
1177111776
my_snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
11772-
"Write_rows_log_event::write_row(%lld)",
11773-
(long long) wsrep_thd_trx_seqno(thd));
11777+
"Write_rows_log_event::write_row(%lld) on table %s",
11778+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str);
1177411779
message= thd->wsrep_info;
1177511780
#endif /* WSREP_PROC_INFO */
1177611781

1177711782
thd_proc_info(thd, message);
11783+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
11784+
my_sleep(500000);
11785+
};);
1177811786
int error= write_row(rgi, slave_exec_mode == SLAVE_EXEC_MODE_IDEMPOTENT);
1177911787
thd_proc_info(thd, tmp);
11788+
thd->db= tmp_db;
1178011789

1178111790
if (error && !thd->is_error())
1178211791
{
@@ -12372,32 +12381,45 @@ int Delete_rows_log_event::do_exec_row(rpl_group_info *rgi)
1237212381
{
1237312382
int error;
1237412383
const char *tmp= thd->get_proc_info();
12375-
const char *message= "Delete_rows_log_event::find_row()";
12384+
char *tmp_db= thd->db;
12385+
char *message, msg[128];
12386+
my_snprintf(msg, sizeof(msg),"Delete_rows_log_event::find_row() on table %s",
12387+
m_table->s->table_name.str);
12388+
thd->db= m_table->s->db.str;
12389+
message= msg;
1237612390
const bool invoke_triggers=
1237712391
slave_run_triggers_for_rbr && !master_had_triggers && m_table->triggers;
1237812392
DBUG_ASSERT(m_table != NULL);
1237912393

1238012394
#ifdef WSREP_PROC_INFO
1238112395
my_snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
12382-
"Delete_rows_log_event::find_row(%lld)",
12383-
(long long) wsrep_thd_trx_seqno(thd));
12396+
"Delete_rows_log_event::find_row(%lld) on table %s",
12397+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str) ;
1238412398
message= thd->wsrep_info;
1238512399
#endif /* WSREP_PROC_INFO */
1238612400

1238712401
thd_proc_info(thd, message);
12402+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
12403+
my_sleep(500000);
12404+
};);
1238812405
if (!(error= find_row(rgi)))
1238912406
{
1239012407
/*
1239112408
Delete the record found, located in record[0]
1239212409
*/
12393-
message= "Delete_rows_log_event::ha_delete_row()";
12410+
my_snprintf(msg, sizeof(msg),"Delete_rows_log_event::ha_delete_row() on table %s",
12411+
m_table->s->table_name.str);
12412+
message= msg;
1239412413
#ifdef WSREP_PROC_INFO
1239512414
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
12396-
"Delete_rows_log_event::ha_delete_row(%lld)",
12397-
(long long) wsrep_thd_trx_seqno(thd));
12415+
"Delete_rows_log_event::ha_delete_row(%lld) on table %s",
12416+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str) ;
1239812417
message= thd->wsrep_info;
1239912418
#endif
1240012419
thd_proc_info(thd, message);
12420+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
12421+
my_sleep(500000);
12422+
};);
1240112423

1240212424
if (invoke_triggers &&
1240312425
process_triggers(TRG_EVENT_DELETE, TRG_ACTION_BEFORE, FALSE))
@@ -12414,6 +12436,7 @@ int Delete_rows_log_event::do_exec_row(rpl_group_info *rgi)
1241412436
m_table->file->ha_index_or_rnd_end();
1241512437
}
1241612438
thd_proc_info(thd, tmp);
12439+
thd->db= tmp_db;
1241712440
return error;
1241812441
}
1241912442

@@ -12532,17 +12555,26 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
1253212555
const bool invoke_triggers=
1253312556
slave_run_triggers_for_rbr && !master_had_triggers && m_table->triggers;
1253412557
const char *tmp= thd->get_proc_info();
12535-
const char *message= "Update_rows_log_event::find_row()";
12558+
char *tmp_db= thd->db;
12559+
char *message, msg[128];
1253612560
DBUG_ASSERT(m_table != NULL);
12561+
my_snprintf(msg, sizeof(msg),"Update_rows_log_event::find_row() on table %s",
12562+
m_table->s->table_name.str);
12563+
thd->db= m_table->s->db.str;
12564+
message= msg;
1253712565

1253812566
#ifdef WSREP_PROC_INFO
1253912567
my_snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
12540-
"Update_rows_log_event::find_row(%lld)",
12541-
(long long) wsrep_thd_trx_seqno(thd));
12568+
"Update_rows_log_event::find_row(%lld) on table %s",
12569+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str) ;
1254212570
message= thd->wsrep_info;
1254312571
#endif /* WSREP_PROC_INFO */
1254412572

1254512573
thd_proc_info(thd, message);
12574+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
12575+
my_sleep(500000);
12576+
};);
12577+
1254612578
int error= find_row(rgi);
1254712579
if (error)
1254812580
{
@@ -12553,6 +12585,7 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
1255312585
if ((m_curr_row= m_curr_row_end))
1255412586
unpack_current_row(rgi, &m_cols_ai);
1255512587
thd_proc_info(thd, tmp);
12588+
thd->db= tmp_db;
1255612589
return error;
1255712590
}
1255812591

@@ -12570,16 +12603,21 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
1257012603
store_record(m_table,record[1]);
1257112604

1257212605
m_curr_row= m_curr_row_end;
12573-
message= "Update_rows_log_event::unpack_current_row()";
12606+
my_snprintf(msg, sizeof(msg),"Update_rows_log_event::unpack_current_row() on table %s",
12607+
m_table->s->table_name.str);
12608+
message= msg;
1257412609
#ifdef WSREP_PROC_INFO
1257512610
my_snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
12576-
"Update_rows_log_event::unpack_current_row(%lld)",
12577-
(long long) wsrep_thd_trx_seqno(thd));
12611+
"Update_rows_log_event::unpack_current_row(%lld) on table %s",
12612+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str) ;
1257812613
message= thd->wsrep_info;
1257912614
#endif /* WSREP_PROC_INFO */
1258012615

1258112616
/* this also updates m_curr_row_end */
1258212617
thd_proc_info(thd, message);
12618+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
12619+
my_sleep(500000);
12620+
};);
1258312621
if ((error= unpack_current_row(rgi, &m_cols_ai)))
1258412622
goto err;
1258512623

@@ -12597,15 +12635,20 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
1259712635
DBUG_DUMP("new values", m_table->record[0], m_table->s->reclength);
1259812636
#endif
1259912637

12600-
message= "Update_rows_log_event::ha_update_row()";
12638+
my_snprintf(msg, sizeof(msg),"Update_rows_log_event::ha_update_row() on table %s",
12639+
m_table->s->table_name.str);
12640+
message= msg;
1260112641
#ifdef WSREP_PROC_INFO
1260212642
my_snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
12603-
"Update_rows_log_event::ha_update_row(%lld)",
12604-
(long long) wsrep_thd_trx_seqno(thd));
12643+
"Update_rows_log_event::ha_update_row(%lld) on table %s",
12644+
(long long) wsrep_thd_trx_seqno(thd), m_table->s->table_name.str) ;
1260512645
message= thd->wsrep_info;
1260612646
#endif /* WSREP_PROC_INFO */
1260712647

1260812648
thd_proc_info(thd, message);
12649+
DBUG_EXECUTE_IF("should_sleep_for_mdev7409",{
12650+
my_sleep(500000);
12651+
};);
1260912652
if (invoke_triggers &&
1261012653
process_triggers(TRG_EVENT_UPDATE, TRG_ACTION_BEFORE, TRUE))
1261112654
{
@@ -12627,9 +12670,9 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
1262712670
process_triggers(TRG_EVENT_UPDATE, TRG_ACTION_AFTER, TRUE))
1262812671
error= HA_ERR_GENERIC; // in case if error is not set yet
1262912672

12630-
thd_proc_info(thd, tmp);
12631-
1263212673
err:
12674+
thd_proc_info(thd, tmp);
12675+
thd->db= tmp_db;
1263312676
m_table->file->ha_index_or_rnd_end();
1263412677
return error;
1263512678
}

0 commit comments

Comments
 (0)