Skip to content

Commit 25b5c63

Browse files
montywibnestere
authored andcommitted
MDEV-33856: Alternative Replication Lag Representation via Received/Executed Master Binlog Event Timestamps
This commit adds 3 new status variables to 'show all slaves status': - Master_last_event_time ; timestamp of the last event read from the master by the IO thread. - Slave_last_event_time ; Master timestamp of the last event committed on the slave. - Master_Slave_time_diff: The difference of the above two timestamps. All the above variables are NULL until the slave has started and the slave has read one query event from the master that changes data. - Added information_schema.slave_status, which allows us to remove: - show_master_info(), show_master_info_get_fields(), send_show_master_info_data(), show_all_master_info() - class Sql_cmd_show_slave_status. - Protocol::store(I_List<i_string_pair>* str_list) as it is not used anymore. - Changed old SHOW SLAVE STATUS and SHOW ALL SLAVES STATUS to use the SELECT code path, as all other SHOW ... STATUS commands. Other things: - Xid_log_time is set to time of commit to allow slave that reads the binary log to calculate Master_last_event_time and Slave_last_event_time. This is needed as there is not 'exec_time' for row events. - Fixed that Load_log_event calculates exec_time identically to Query_event. - Updated RESET SLAVE to reset Master/Slave_last_event_time - Updated SQL thread's update on first transaction read-in to only update Slave_last_event_time on group events. - Fixed possible (unlikely) bugs in sql_show.cc ...old_format() functions if allocation of 'field' would fail. Reviewed By: Brandon Nesterenko <brandon.nesterenko@mariadb.com> Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent 4dde925 commit 25b5c63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1927
-780
lines changed

mysql-test/include/show_slave_status.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if ($all_slaves_status)
9797
{
9898
--die Bug in test case: Both $all_slaves_status and $slave_name are set.
9999
}
100-
--let $_show_query=SHOW ALL SLAVES STATUS
100+
--let $_show_query=SELECT * from information_schema.slave_status
101101
}
102102
if ($slave_name)
103103
{

mysql-test/main/grant_slave_monitor.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, F
1313
#
1414
SHOW SLAVE STATUS;
1515
ERROR 42000: Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation
16+
SELECT * from information_schema.slave_status;
17+
ERROR 42000: Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation
1618
#
1719
# Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW RELAYLOG EVENTS
1820
# Expected error: Access denied; you need (at least one of) the REPLICA MONITOR

mysql-test/main/grant_slave_monitor.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ SHOW GRANTS;
3838
--echo #
3939
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
4040
SHOW SLAVE STATUS;
41+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
42+
SELECT * from information_schema.slave_status;
4143

4244
--echo #
4345
--echo # Verify that having REPLICATION SLAVE ADMIN doesn't allow SHOW RELAYLOG EVENTS

mysql-test/main/information_schema-big.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
5252
SEQUENCES SEQUENCE_SCHEMA
5353
SESSION_STATUS VARIABLE_NAME
5454
SESSION_VARIABLES VARIABLE_NAME
55+
SLAVE_STATUS Connection_name
5556
SPATIAL_REF_SYS SRID
5657
SQL_FUNCTIONS FUNCTION
5758
STATISTICS TABLE_SCHEMA
@@ -117,6 +118,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
117118
SEQUENCES SEQUENCE_SCHEMA
118119
SESSION_STATUS VARIABLE_NAME
119120
SESSION_VARIABLES VARIABLE_NAME
121+
SLAVE_STATUS Connection_name
120122
SPATIAL_REF_SYS SRID
121123
SQL_FUNCTIONS FUNCTION
122124
STATISTICS TABLE_SCHEMA

mysql-test/main/information_schema-big.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- source include/have_innodb.inc
2+
-- source include/not_embedded.inc
23

34
# check that CSV engine was compiled in, as the result of the test depends
45
# on the presence of the log tables (which are CSV-based).
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#
2+
# Bug#18925: subqueries with MIN/MAX functions on INFORMATION_SCHEMA
3+
#
4+
SELECT t.table_name, c1.column_name
5+
FROM information_schema.tables t
6+
INNER JOIN
7+
information_schema.columns c1
8+
ON t.table_schema = c1.table_schema AND
9+
t.table_name = c1.table_name
10+
WHERE t.table_schema = 'information_schema' AND
11+
c1.ordinal_position =
12+
( SELECT COALESCE(MIN(c2.ordinal_position),1)
13+
FROM information_schema.columns c2
14+
WHERE c2.table_schema = t.table_schema AND
15+
c2.table_name = t.table_name AND
16+
c2.column_name LIKE '%SCHEMA%'
17+
)
18+
AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%";
19+
table_name column_name
20+
ALL_PLUGINS PLUGIN_NAME
21+
APPLICABLE_ROLES GRANTEE
22+
CHARACTER_SETS CHARACTER_SET_NAME
23+
CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
24+
CLIENT_STATISTICS CLIENT
25+
COLLATIONS COLLATION_NAME
26+
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
27+
COLUMNS TABLE_SCHEMA
28+
COLUMN_PRIVILEGES TABLE_SCHEMA
29+
ENABLED_ROLES ROLE_NAME
30+
ENGINES ENGINE
31+
EVENTS EVENT_SCHEMA
32+
FILES TABLE_SCHEMA
33+
GEOMETRY_COLUMNS F_TABLE_SCHEMA
34+
GLOBAL_STATUS VARIABLE_NAME
35+
GLOBAL_VARIABLES VARIABLE_NAME
36+
INDEX_STATISTICS TABLE_SCHEMA
37+
KEYWORDS WORD
38+
KEY_CACHES KEY_CACHE_NAME
39+
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
40+
KEY_PERIOD_USAGE CONSTRAINT_SCHEMA
41+
OPTIMIZER_COSTS ENGINE
42+
PARAMETERS SPECIFIC_SCHEMA
43+
PARTITIONS TABLE_SCHEMA
44+
PERIODS TABLE_SCHEMA
45+
PLUGINS PLUGIN_NAME
46+
PROCESSLIST ID
47+
PROFILING QUERY_ID
48+
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
49+
ROUTINES ROUTINE_SCHEMA
50+
SCHEMATA SCHEMA_NAME
51+
SCHEMA_PRIVILEGES TABLE_SCHEMA
52+
SEQUENCES SEQUENCE_SCHEMA
53+
SESSION_STATUS VARIABLE_NAME
54+
SESSION_VARIABLES VARIABLE_NAME
55+
SPATIAL_REF_SYS SRID
56+
SQL_FUNCTIONS FUNCTION
57+
STATISTICS TABLE_SCHEMA
58+
SYSTEM_VARIABLES VARIABLE_NAME
59+
TABLES TABLE_SCHEMA
60+
TABLESPACES TABLESPACE_NAME
61+
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
62+
TABLE_PRIVILEGES TABLE_SCHEMA
63+
TABLE_STATISTICS TABLE_SCHEMA
64+
TRIGGERS TRIGGER_SCHEMA
65+
USERS USER
66+
USER_PRIVILEGES GRANTEE
67+
USER_STATISTICS USER
68+
VIEWS TABLE_SCHEMA
69+
SELECT t.table_name, c1.column_name
70+
FROM information_schema.tables t
71+
INNER JOIN
72+
information_schema.columns c1
73+
ON t.table_schema = c1.table_schema AND
74+
t.table_name = c1.table_name
75+
WHERE t.table_schema = 'information_schema' AND
76+
c1.ordinal_position =
77+
( SELECT COALESCE(MIN(c2.ordinal_position),1)
78+
FROM information_schema.columns c2
79+
WHERE c2.table_schema = 'information_schema' AND
80+
c2.table_name = t.table_name AND
81+
c2.column_name LIKE '%SCHEMA%'
82+
)
83+
AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%";
84+
table_name column_name
85+
ALL_PLUGINS PLUGIN_NAME
86+
APPLICABLE_ROLES GRANTEE
87+
CHARACTER_SETS CHARACTER_SET_NAME
88+
CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
89+
CLIENT_STATISTICS CLIENT
90+
COLLATIONS COLLATION_NAME
91+
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
92+
COLUMNS TABLE_SCHEMA
93+
COLUMN_PRIVILEGES TABLE_SCHEMA
94+
ENABLED_ROLES ROLE_NAME
95+
ENGINES ENGINE
96+
EVENTS EVENT_SCHEMA
97+
FILES TABLE_SCHEMA
98+
GEOMETRY_COLUMNS F_TABLE_SCHEMA
99+
GLOBAL_STATUS VARIABLE_NAME
100+
GLOBAL_VARIABLES VARIABLE_NAME
101+
INDEX_STATISTICS TABLE_SCHEMA
102+
KEYWORDS WORD
103+
KEY_CACHES KEY_CACHE_NAME
104+
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
105+
KEY_PERIOD_USAGE CONSTRAINT_SCHEMA
106+
OPTIMIZER_COSTS ENGINE
107+
PARAMETERS SPECIFIC_SCHEMA
108+
PARTITIONS TABLE_SCHEMA
109+
PERIODS TABLE_SCHEMA
110+
PLUGINS PLUGIN_NAME
111+
PROCESSLIST ID
112+
PROFILING QUERY_ID
113+
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
114+
ROUTINES ROUTINE_SCHEMA
115+
SCHEMATA SCHEMA_NAME
116+
SCHEMA_PRIVILEGES TABLE_SCHEMA
117+
SEQUENCES SEQUENCE_SCHEMA
118+
SESSION_STATUS VARIABLE_NAME
119+
SESSION_VARIABLES VARIABLE_NAME
120+
SPATIAL_REF_SYS SRID
121+
SQL_FUNCTIONS FUNCTION
122+
STATISTICS TABLE_SCHEMA
123+
SYSTEM_VARIABLES VARIABLE_NAME
124+
TABLES TABLE_SCHEMA
125+
TABLESPACES TABLESPACE_NAME
126+
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
127+
TABLE_PRIVILEGES TABLE_SCHEMA
128+
TABLE_STATISTICS TABLE_SCHEMA
129+
TRIGGERS TRIGGER_SCHEMA
130+
USERS USER
131+
USER_PRIVILEGES GRANTEE
132+
USER_STATISTICS USER
133+
VIEWS TABLE_SCHEMA
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- source include/have_innodb.inc
2+
-- source include/is_embedded.inc
3+
4+
# check that CSV engine was compiled in, as the result of the test depends
5+
# on the presence of the log tables (which are CSV-based).
6+
--source include/have_csv.inc
7+
8+
--echo #
9+
--echo # Bug#18925: subqueries with MIN/MAX functions on INFORMATION_SCHEMA
10+
--echo #
11+
12+
--sorted_result
13+
SELECT t.table_name, c1.column_name
14+
FROM information_schema.tables t
15+
INNER JOIN
16+
information_schema.columns c1
17+
ON t.table_schema = c1.table_schema AND
18+
t.table_name = c1.table_name
19+
WHERE t.table_schema = 'information_schema' AND
20+
c1.ordinal_position =
21+
( SELECT COALESCE(MIN(c2.ordinal_position),1)
22+
FROM information_schema.columns c2
23+
WHERE c2.table_schema = t.table_schema AND
24+
c2.table_name = t.table_name AND
25+
c2.column_name LIKE '%SCHEMA%'
26+
)
27+
AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%";
28+
--sorted_result
29+
SELECT t.table_name, c1.column_name
30+
FROM information_schema.tables t
31+
INNER JOIN
32+
information_schema.columns c1
33+
ON t.table_schema = c1.table_schema AND
34+
t.table_name = c1.table_name
35+
WHERE t.table_schema = 'information_schema' AND
36+
c1.ordinal_position =
37+
( SELECT COALESCE(MIN(c2.ordinal_position),1)
38+
FROM information_schema.columns c2
39+
WHERE c2.table_schema = 'information_schema' AND
40+
c2.table_name = t.table_name AND
41+
c2.column_name LIKE '%SCHEMA%'
42+
)
43+
AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%";

mysql-test/main/information_schema.result

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ SCHEMA_PRIVILEGES
8787
SEQUENCES
8888
SESSION_STATUS
8989
SESSION_VARIABLES
90+
SLAVE_STATUS
9091
SPATIAL_REF_SYS
9192
SQL_FUNCTIONS
9293
STATISTICS
@@ -960,6 +961,8 @@ PARTITIONS UPDATE_TIME datetime
960961
PARTITIONS CHECK_TIME datetime
961962
ROUTINES CREATED datetime
962963
ROUTINES LAST_ALTERED datetime
964+
SLAVE_STATUS Master_last_event_time datetime
965+
SLAVE_STATUS Slave_last_event_time datetime
963966
TABLES CREATE_TIME datetime
964967
TABLES UPDATE_TIME datetime
965968
TABLES CHECK_TIME datetime
@@ -1336,8 +1339,8 @@ table_schema='information_schema' and
13361339
or column_type = 'varchar(27)')
13371340
group by column_type order by num;
13381341
column_type group_concat(table_schema, '.', table_name) num
1339-
varchar(7) information_schema.ROUTINES,information_schema.VIEWS2
1340-
varchar(20) information_schema.ALL_PLUGINS,information_schema.ALL_PLUGINS,information_schema.ALL_PLUGINS,information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PROFILING9
1342+
varchar(7) information_schema.ROUTINES,information_schema.VIEWS,information_schema.SLAVE_STATUS 3
1343+
varchar(20) information_schema.ALL_PLUGINS,information_schema.ALL_PLUGINS,information_schema.ALL_PLUGINS,information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PROFILING,information_schema.SLAVE_STATUS 10
13411344
create table t1(f1 char(1) not null, f2 char(9) not null)
13421345
default character set utf8;
13431346
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from

mysql-test/main/information_schema_all_engines.result

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ SCHEMA_PRIVILEGES
5858
SEQUENCES
5959
SESSION_STATUS
6060
SESSION_VARIABLES
61+
SLAVE_STATUS
6162
SPATIAL_REF_SYS
6263
SQL_FUNCTIONS
6364
STATISTICS
@@ -144,6 +145,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
144145
SEQUENCES SEQUENCE_SCHEMA
145146
SESSION_STATUS VARIABLE_NAME
146147
SESSION_VARIABLES VARIABLE_NAME
148+
SLAVE_STATUS Connection_name
147149
SPATIAL_REF_SYS SRID
148150
SQL_FUNCTIONS FUNCTION
149151
STATISTICS TABLE_SCHEMA
@@ -230,6 +232,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
230232
SEQUENCES SEQUENCE_SCHEMA
231233
SESSION_STATUS VARIABLE_NAME
232234
SESSION_VARIABLES VARIABLE_NAME
235+
SLAVE_STATUS Connection_name
233236
SPATIAL_REF_SYS SRID
234237
SQL_FUNCTIONS FUNCTION
235238
STATISTICS TABLE_SCHEMA
@@ -278,8 +281,6 @@ ENGINES information_schema.ENGINES 1
278281
EVENTS information_schema.EVENTS 1
279282
FILES information_schema.FILES 1
280283
GEOMETRY_COLUMNS information_schema.GEOMETRY_COLUMNS 1
281-
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
282-
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
283284
INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
284285
INNODB_BUFFER_PAGE information_schema.INNODB_BUFFER_PAGE 1
285286
INNODB_BUFFER_PAGE_LRU information_schema.INNODB_BUFFER_PAGE_LRU 1
@@ -318,8 +319,7 @@ ROUTINES information_schema.ROUTINES 1
318319
SCHEMATA information_schema.SCHEMATA 1
319320
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
320321
SEQUENCES information_schema.SEQUENCES 1
321-
SESSION_STATUS information_schema.SESSION_STATUS 1
322-
SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
322+
SLAVE_STATUS information_schema.SLAVE_STATUS 1
323323
SPATIAL_REF_SYS information_schema.SPATIAL_REF_SYS 1
324324
STATISTICS information_schema.STATISTICS 1
325325
SYSTEM_VARIABLES information_schema.SYSTEM_VARIABLES 1
@@ -395,6 +395,7 @@ Database: information_schema
395395
| SEQUENCES |
396396
| SESSION_STATUS |
397397
| SESSION_VARIABLES |
398+
| SLAVE_STATUS |
398399
| SPATIAL_REF_SYS |
399400
| SQL_FUNCTIONS |
400401
| STATISTICS |
@@ -471,6 +472,7 @@ Database: INFORMATION_SCHEMA
471472
| SEQUENCES |
472473
| SESSION_STATUS |
473474
| SESSION_VARIABLES |
475+
| SLAVE_STATUS |
474476
| SPATIAL_REF_SYS |
475477
| SQL_FUNCTIONS |
476478
| STATISTICS |
@@ -493,5 +495,5 @@ Wildcard: inf_rmation_schema
493495
| information_schema |
494496
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') GROUP BY TABLE_SCHEMA;
495497
table_schema count(*)
496-
information_schema71
498+
information_schema72
497499
mysql 31

mysql-test/main/ps_change_master.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ EXECUTE stmt;
3232
EXECUTE stmt;
3333
DEALLOCATE PREPARE stmt;
3434

35-
let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
36-
let $master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1);
35+
let $master_host= `select Master_Host from information_schema.slave_status`;
36+
let $master_user= `select Master_user from information_schema.slave_status`;
3737

3838
--echo # Master_Host : $master_host
3939
--echo # Master_User : $master_user

0 commit comments

Comments
 (0)