Skip to content

Commit dc1e488

Browse files
V S Murthy Sidagamdahlerlend
authored andcommitted
Bug#24453571 SERVER CRASHES WHEN INSTALL COMPONENT IS ISSUED, AFTER MYSQL_UPGRADE
Description: mysql server crashes while running INSTALL COMPONENT, after mysql_upgrade Analysis: When the server is started with out mysql.component table in database, mysql_persistent_dynamic_loader_imp::init() call fails with the error. Becasue open_component_table() is failing because of mysql.component table is not present. And later if we give INSTALL COMPONENT it will call mysql_persistent_dynamic_loader_imp::load() and it fails at mysql_persistent_dynamic_loader_imp::is_initialized condition because this flag is not set at init() time. And there is no error set along with this failure. Hence the crash at THD::send_statement_status() at the end of query exicution. Fix: In init() function pretend that the initialization succeeded and make the group_id as '0'. And also return the error messages when the is_initialized flag is checked at load()/unload() function so, that the proper error message is send to the client. By pretending the initialization it will help incase of mysql_upgrade.
1 parent f57a845 commit dc1e488

File tree

4 files changed

+143
-2
lines changed

4 files changed

+143
-2
lines changed

mysql-test/r/component-upgrade.result

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#
2+
# Bug #24453571 SERVER CRASHES WHEN INSTALL COMPONENT IS ISSUED,
3+
# AFTER MYSQL_UPGRADE
4+
#
5+
# Checking MYSQL_UPGRADE creates the missing mysql.component table
6+
# when upgrading from 5.7. Simulating the senario by deleting the
7+
# component table.
8+
CALL mtr.add_suppression("Table 'mysql.component' doesn't exis");
9+
CALL mtr.add_suppression("The mysql.component table is missing or has an incorrect definition.");
10+
Run mysql_upgrade once
11+
mysql.column_stats OK
12+
mysql.columns_priv OK
13+
mysql.component OK
14+
mysql.db OK
15+
mysql.default_roles OK
16+
mysql.engine_cost OK
17+
mysql.func OK
18+
mysql.general_log OK
19+
mysql.gtid_executed OK
20+
mysql.help_category OK
21+
mysql.help_keyword OK
22+
mysql.help_relation OK
23+
mysql.help_topic OK
24+
mysql.innodb_index_stats OK
25+
mysql.innodb_table_stats OK
26+
mysql.plugin OK
27+
mysql.procs_priv OK
28+
mysql.proxies_priv OK
29+
mysql.role_edges OK
30+
mysql.server_cost OK
31+
mysql.servers OK
32+
mysql.slave_master_info OK
33+
mysql.slave_relay_log_info OK
34+
mysql.slave_worker_info OK
35+
mysql.slow_log OK
36+
mysql.tables_priv OK
37+
mysql.time_zone OK
38+
mysql.time_zone_leap_second OK
39+
mysql.time_zone_name OK
40+
mysql.time_zone_transition OK
41+
mysql.time_zone_transition_type OK
42+
mysql.user OK
43+
mtr.global_suppressions OK
44+
mtr.test_suppressions OK
45+
sys.sys_config OK
46+
# Dropping component table.
47+
DROP TABLE mysql.component;
48+
# shutdown the server from mtr.
49+
# restart the server.
50+
# running mysql_upgrade
51+
mysql.column_stats OK
52+
mysql.columns_priv OK
53+
mysql.component OK
54+
mysql.db OK
55+
mysql.default_roles OK
56+
mysql.engine_cost OK
57+
mysql.func OK
58+
mysql.general_log OK
59+
mysql.gtid_executed OK
60+
mysql.help_category OK
61+
mysql.help_keyword OK
62+
mysql.help_relation OK
63+
mysql.help_topic OK
64+
mysql.innodb_index_stats OK
65+
mysql.innodb_table_stats OK
66+
mysql.plugin OK
67+
mysql.procs_priv OK
68+
mysql.proxies_priv OK
69+
mysql.role_edges OK
70+
mysql.server_cost OK
71+
mysql.servers OK
72+
mysql.slave_master_info OK
73+
mysql.slave_relay_log_info OK
74+
mysql.slave_worker_info OK
75+
mysql.slow_log OK
76+
mysql.tables_priv OK
77+
mysql.time_zone OK
78+
mysql.time_zone_leap_second OK
79+
mysql.time_zone_name OK
80+
mysql.time_zone_transition OK
81+
mysql.time_zone_transition_type OK
82+
mysql.user OK
83+
mtr.global_suppressions OK
84+
mtr.test_suppressions OK
85+
sys.sys_config OK
86+
INSTALL COMPONENT "file://component_example_component1";
87+
# a component should present
88+
SELECT COUNT(*) FROM mysql.component;
89+
COUNT(*)
90+
1
91+
UNINSTALL COMPONENT "file://component_example_component1";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$EXAMPLE_COMPONENT_1_OPT

mysql-test/t/component-upgrade.test

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Temporarily skipped with binary logging due to Bug#24343582
2+
--source include/not_log_bin.inc
3+
4+
--source include/not_embedded.inc
5+
--source include/have_example_component.inc
6+
--source include/no_valgrind_without_big.inc
7+
--source include/mysql_upgrade_preparation.inc
8+
9+
--echo #
10+
--echo # Bug #24453571 SERVER CRASHES WHEN INSTALL COMPONENT IS ISSUED,
11+
--echo # AFTER MYSQL_UPGRADE
12+
--echo #
13+
14+
--echo # Checking MYSQL_UPGRADE creates the missing mysql.component table
15+
--echo # when upgrading from 5.7. Simulating the senario by deleting the
16+
--echo # component table.
17+
18+
CALL mtr.add_suppression("Table 'mysql.component' doesn't exis");
19+
CALL mtr.add_suppression("The mysql.component table is missing or has an incorrect definition.");
20+
# Basic test that we can run mysql_upgrde and that it finds the expected
21+
# binaries it uses.
22+
--echo Run mysql_upgrade once
23+
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
24+
25+
# It should have created a file in the MySQL Servers datadir
26+
let $MYSQLD_DATADIR= `select @@datadir`;
27+
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;
28+
29+
--echo # Dropping component table.
30+
DROP TABLE mysql.component;
31+
--echo # shutdown the server from mtr.
32+
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
33+
--shutdown_server
34+
--source include/wait_until_disconnected.inc
35+
36+
--echo # restart the server.
37+
--exec echo "restart:" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
38+
--enable_reconnect
39+
--source include/wait_until_connected_again.inc
40+
--echo # running mysql_upgrade
41+
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
42+
--source include/have_example_component.inc
43+
INSTALL COMPONENT "file://component_example_component1";
44+
--echo # a component should present
45+
SELECT COUNT(*) FROM mysql.component;
46+
UNINSTALL COMPONENT "file://component_example_component1";

sql/persistent_dynamic_loader.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,15 @@ bool mysql_persistent_dynamic_loader_imp::init(void* thdp)
183183
READ_RECORD read_record_info;
184184
int res;
185185

186+
mysql_persistent_dynamic_loader_imp::group_id= 0;
187+
186188
/* Open component table and scan read all records. */
187189
if (open_component_table(thd, TL_READ, &component_table, NULL))
188190
{
189191
push_warning(thd, Sql_condition::SL_WARNING,
190192
ER_COMPONENT_TABLE_INCORRECT,
191193
ER_THD(thd, ER_COMPONENT_TABLE_INCORRECT));
194+
mysql_persistent_dynamic_loader_imp::is_initialized= true;
192195
return false;
193196
}
194197

@@ -214,8 +217,6 @@ bool mysql_persistent_dynamic_loader_imp::init(void* thdp)
214217
return false;
215218
}
216219

217-
mysql_persistent_dynamic_loader_imp::group_id= 0;
218-
219220
/* All read records will be aggregated in groups by group ID. */
220221
std::map<uint64, std::vector<std::string> > component_groups;
221222

@@ -317,6 +318,7 @@ DEFINE_BOOL_METHOD(mysql_persistent_dynamic_loader_imp::load,
317318

318319
if (!mysql_persistent_dynamic_loader_imp::is_initialized)
319320
{
321+
my_error(ER_COMPONENT_TABLE_INCORRECT, MYF(0));
320322
return true;
321323
}
322324

@@ -417,6 +419,7 @@ DEFINE_BOOL_METHOD(mysql_persistent_dynamic_loader_imp::unload,
417419

418420
if (!mysql_persistent_dynamic_loader_imp::is_initialized)
419421
{
422+
my_error(ER_COMPONENT_TABLE_INCORRECT, MYF(0));
420423
return true;
421424
}
422425

0 commit comments

Comments
 (0)