]>
Commit | Line | Data |
---|---|---|
b4e1fa2c AM |
1 | # name : show_slave_status_nolock.patch |
2 | # introduced : 12 | |
3 | # maintainer : Oleg | |
4 | # | |
5 | #!!! notice !!! | |
6 | # Any small change to this file in the main branch | |
7 | # should be done or reviewed by the maintainer! | |
db82db79 AM |
8 | --- /dev/null |
9 | +++ b/patch_info/show_slave_status_nolock.patch | |
b4e1fa2c AM |
10 | @@ -0,0 +1,6 @@ |
11 | +File=show_slave_status_nolock.patch | |
12 | +Name= SHOW SLAVE STATUS NOLOCK | |
13 | +Version=1.0 | |
14 | +Author=Percona <info@percona.com> | |
15 | +License=GPL | |
16 | +Comment= Implement SHOW SLAVE STATUS without lock (STOP SLAVE lock the same mutex what lock SHOW SLAVE STATUS) | |
db82db79 AM |
17 | --- a/sql/lex.h |
18 | +++ b/sql/lex.h | |
b4e1fa2c AM |
19 | @@ -378,6 +378,7 @@ |
20 | { "NONE", SYM(NONE_SYM)}, | |
21 | { "NOT", SYM(NOT_SYM)}, | |
22 | { "NO_WRITE_TO_BINLOG", SYM(NO_WRITE_TO_BINLOG)}, | |
23 | + { "NOLOCK", SYM(NOLOCK_SYM)}, | |
24 | { "NULL", SYM(NULL_SYM)}, | |
25 | { "NUMERIC", SYM(NUMERIC_SYM)}, | |
26 | { "NVARCHAR", SYM(NVARCHAR_SYM)}, | |
db82db79 AM |
27 | --- a/sql/mysqld.cc |
28 | +++ b/sql/mysqld.cc | |
29 | @@ -3121,6 +3121,7 @@ | |
b4e1fa2c AM |
30 | {"show_relaylog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_RELAYLOG_EVENTS]), SHOW_LONG_STATUS}, |
31 | {"show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS}, | |
32 | {"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS}, | |
33 | + {"show_slave_status_nolock", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_NOLOCK_STAT]), SHOW_LONG_STATUS}, | |
34 | {"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS}, | |
35 | {"show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS}, | |
36 | {"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS}, | |
db82db79 AM |
37 | --- a/sql/sql_lex.h |
38 | +++ b/sql/sql_lex.h | |
b4e1fa2c AM |
39 | @@ -190,6 +190,8 @@ |
40 | SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES, | |
41 | SQLCOM_SIGNAL, SQLCOM_RESIGNAL, | |
42 | SQLCOM_SHOW_RELAYLOG_EVENTS, | |
43 | + /* SHOW SLAVE STATUS NOLOCK */ | |
44 | + SQLCOM_SHOW_SLAVE_NOLOCK_STAT, | |
45 | /* | |
46 | When a command is added here, be sure it's also added in mysqld.cc | |
47 | in "struct show_var_st status_vars[]= {" ... | |
db82db79 AM |
48 | --- a/sql/sql_parse.cc |
49 | +++ b/sql/sql_parse.cc | |
11822e22 | 50 | @@ -335,6 +335,7 @@ |
b4e1fa2c AM |
51 | sql_command_flags[SQLCOM_SHOW_CREATE]= CF_STATUS_COMMAND; |
52 | sql_command_flags[SQLCOM_SHOW_MASTER_STAT]= CF_STATUS_COMMAND; | |
53 | sql_command_flags[SQLCOM_SHOW_SLAVE_STAT]= CF_STATUS_COMMAND; | |
54 | + sql_command_flags[SQLCOM_SHOW_SLAVE_NOLOCK_STAT]= CF_STATUS_COMMAND; | |
55 | sql_command_flags[SQLCOM_SHOW_CREATE_PROC]= CF_STATUS_COMMAND; | |
56 | sql_command_flags[SQLCOM_SHOW_CREATE_FUNC]= CF_STATUS_COMMAND; | |
57 | sql_command_flags[SQLCOM_SHOW_CREATE_TRIGGER]= CF_STATUS_COMMAND; | |
db82db79 | 58 | @@ -2359,12 +2360,16 @@ |
b4e1fa2c AM |
59 | mysql_mutex_unlock(&LOCK_active_mi); |
60 | break; | |
61 | } | |
62 | + case SQLCOM_SHOW_SLAVE_NOLOCK_STAT: | |
63 | case SQLCOM_SHOW_SLAVE_STAT: | |
64 | { | |
65 | /* Accept one of two privileges */ | |
66 | if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) | |
67 | goto error; | |
68 | - mysql_mutex_lock(&LOCK_active_mi); | |
69 | + if(SQLCOM_SHOW_SLAVE_NOLOCK_STAT != lex->sql_command) | |
70 | + { | |
71 | + mysql_mutex_lock(&LOCK_active_mi); | |
72 | + } | |
73 | if (active_mi != NULL) | |
74 | { | |
75 | res = show_master_info(thd, active_mi); | |
db82db79 | 76 | @@ -2375,7 +2380,10 @@ |
b4e1fa2c AM |
77 | WARN_NO_MASTER_INFO, ER(WARN_NO_MASTER_INFO)); |
78 | my_ok(thd); | |
79 | } | |
80 | - mysql_mutex_unlock(&LOCK_active_mi); | |
81 | + if(SQLCOM_SHOW_SLAVE_NOLOCK_STAT != lex->sql_command) | |
82 | + { | |
83 | + mysql_mutex_unlock(&LOCK_active_mi); | |
84 | + } | |
85 | break; | |
86 | } | |
87 | case SQLCOM_SHOW_MASTER_STAT: | |
db82db79 AM |
88 | --- a/sql/sql_yacc.yy |
89 | +++ b/sql/sql_yacc.yy | |
90 | @@ -1293,6 +1293,7 @@ | |
b4e1fa2c AM |
91 | %token STARTS_SYM |
92 | %token START_SYM /* SQL-2003-R */ | |
93 | %token STATUS_SYM | |
94 | +%token NOLOCK_SYM /* SHOW SLAVE STATUS NOLOCK */ | |
95 | %token STDDEV_SAMP_SYM /* SQL-2003-N */ | |
96 | %token STD_SYM | |
97 | %token STOP_SYM | |
db82db79 | 98 | @@ -11086,6 +11087,10 @@ |
b4e1fa2c AM |
99 | { |
100 | Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT; | |
101 | } | |
102 | + | SLAVE STATUS_SYM NOLOCK_SYM | |
103 | + { | |
104 | + Lex->sql_command = SQLCOM_SHOW_SLAVE_NOLOCK_STAT; //SQLCOM_SHOW_SLAVE_NOLOCK_STAT; | |
105 | + } | |
106 | | QUERY_RESPONSE_TIME_SYM wild_and_where | |
107 | { | |
108 | #ifdef HAVE_RESPONSE_TIME_DISTRIBUTION |