Skip to content

Commit f7b75ce

Browse files
committed
Bug#32550019 Missing check for ndb_schema_result leads to schema dist
timeout Problem: Random test failure in util_table_drop.test with message "Schema distribution timeout". This test checks that dropping the ndb_schema, ndb_schema_result and ndb_apply_status tables from NDB are handled gracefull by the ndbcluster plugin. Analysis: When dropping of ndb_schema_result table occurs during a DDL query, the DDL query will hang until the schema distribution timeout is later detected. Detecting timeout is a good fall back mechanicm but the dropped table should be detected immediately since event subscription is setup on the ndb_schema_result table. Fix: Change the schema distribution client to check that ndb_schema_result table is available and event subscriptions are active, this is done both when preparing and while waiting for replies to arrive. This patch also fixes the root cause of "Bug#33318201 Mysqld crashes when coordinator receive stale schema event " and the testcase for that bug is removed as no longer possible to provoke. Change-Id: Ib5d9c65f8710c27d56946b09d8a38e7fc8946fde
1 parent e931652 commit f7b75ce

File tree

6 files changed

+22
-89
lines changed

6 files changed

+22
-89
lines changed

mysql-test/suite/ndbcluster/stale_schema_event.cnf

Lines changed: 0 additions & 12 deletions
This file was deleted.

mysql-test/suite/ndbcluster/stale_schema_event.result

Lines changed: 0 additions & 10 deletions
This file was deleted.

mysql-test/suite/ndbcluster/stale_schema_event.test

Lines changed: 0 additions & 59 deletions
This file was deleted.

storage/ndb/plugin/ha_ndbcluster_binlog.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,8 @@ bool Ndb_schema_dist_client::log_schema_op_impl(
11771177
}
11781178

11791179
// Check if schema distribution is still ready.
1180-
if (m_share->have_event_operation() == false) {
1180+
if (m_share->have_event_operation() == false ||
1181+
m_result_share->have_event_operation() == false) {
11811182
// This case is unlikely, but there is small race between
11821183
// clients first check for schema distribution ready and schema op
11831184
// registered in the coordinator(since the message is passed
@@ -4272,11 +4273,6 @@ class Ndb_schema_event_handler {
42724273
// take the GSL properly
42734274
assert(!m_thd_ndb->check_option(Thd_ndb::IS_SCHEMA_DIST_PARTICIPANT));
42744275

4275-
// Sleep here will make other mysql server in same cluster setup to create
4276-
// the schema result table in NDB before this mysql server. This also makes
4277-
// the create table in the connection thread to acquire GSL before the
4278-
// Binlog thread
4279-
DBUG_EXECUTE_IF("ndb_bi_sleep_before_gsl", sleep(1););
42804276
// Protect the setup with GSL(Global Schema Lock)
42814277
Ndb_global_schema_lock_guard global_schema_lock_guard(m_thd);
42824278
if (global_schema_lock_guard.lock()) {

storage/ndb/plugin/ndb_schema_dist.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ bool Ndb_schema_dist_client::prepare(const char *db, const char *tabname) {
138138
return false;
139139
}
140140

141+
// Acquire reference also on mysql.ndb_schema_result
142+
m_result_share = NDB_SHARE::acquire_reference(
143+
Ndb_schema_result_table::DB_NAME.c_str(),
144+
Ndb_schema_result_table::TABLE_NAME.c_str(), m_share_reference.c_str());
145+
if (m_result_share == nullptr ||
146+
m_result_share->have_event_operation() == false) {
147+
// The mysql.ndb_schema_result hasn't been created or not setup yet ->
148+
// schema distribution is not ready
149+
push_warning(m_thd, Sql_condition::SL_WARNING, ER_GET_ERRMSG,
150+
"Schema distribution is not ready (ndb_schema_result)");
151+
return false;
152+
}
153+
141154
if (unlikely(m_ddl_blocked)) {
142155
// If a data node gets upgraded after this MySQL Server is upgraded, this
143156
// MySQL Server will not be aware of the upgrade due to Bug#30930132.
@@ -286,6 +299,10 @@ Ndb_schema_dist_client::~Ndb_schema_dist_client() {
286299
// Release the reference to mysql.ndb_schema table
287300
NDB_SHARE::release_reference(m_share, m_share_reference.c_str());
288301
}
302+
if (m_result_share) {
303+
// Release the reference to mysql.ndb_schema_result table
304+
NDB_SHARE::release_reference(m_result_share, m_share_reference.c_str());
305+
}
289306

290307
if (m_thd_ndb) {
291308
// Inform Applier that one schema distribution has completed
@@ -373,9 +390,9 @@ bool Ndb_schema_dist_client::log_schema_op(const char *query,
373390
return false;
374391
}
375392

376-
// Require that m_share has been initialized to reference the
377-
// schema distribution table
393+
// Require that references to schema distribution tables has been initialized
378394
ndbcluster::ndbrequire(m_share);
395+
ndbcluster::ndbrequire(m_result_share);
379396

380397
// Check that prepared keys match
381398
if (!m_prepared_keys.check_key(db, table_name)) {

storage/ndb/plugin/ndb_schema_dist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class Ndb_schema_dist_client {
130130
class THD *const m_thd;
131131
class Thd_ndb *const m_thd_ndb;
132132
struct NDB_SHARE *m_share{nullptr};
133+
struct NDB_SHARE *m_result_share{nullptr};
133134
const std::string m_share_reference;
134135
class Prepared_keys {
135136
using Key = std::pair<std::string, std::string>;

0 commit comments

Comments
 (0)