Commit c86dcfd9 authored by unknown's avatar unknown

Invalidate table including all it's indexes from binlog thread

parent 42f8c2d2
...@@ -519,6 +519,7 @@ void ha_ndbcluster::invalidate_dictionary_cache(bool global) ...@@ -519,6 +519,7 @@ void ha_ndbcluster::invalidate_dictionary_cache(bool global)
{ {
NDBINDEX *index = (NDBINDEX *) m_index[i].index; NDBINDEX *index = (NDBINDEX *) m_index[i].index;
NDBINDEX *unique_index = (NDBINDEX *) m_index[i].unique_index; NDBINDEX *unique_index = (NDBINDEX *) m_index[i].unique_index;
if (!index && !unique_index) continue;
NDB_INDEX_TYPE idx_type= m_index[i].type; NDB_INDEX_TYPE idx_type= m_index[i].type;
switch (idx_type) { switch (idx_type) {
...@@ -1076,7 +1077,7 @@ int ha_ndbcluster::get_metadata(const char *path) ...@@ -1076,7 +1077,7 @@ int ha_ndbcluster::get_metadata(const char *path)
m_table= (void *)tab; m_table= (void *)tab;
m_table_info= NULL; // Set in external lock m_table_info= NULL; // Set in external lock
DBUG_RETURN(open_indexes(ndb, table)); DBUG_RETURN(open_indexes(ndb, table, FALSE));
} }
static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
...@@ -1249,7 +1250,7 @@ int ha_ndbcluster::add_index_handle(THD *thd, NDBDICT *dict, KEY *key_info, ...@@ -1249,7 +1250,7 @@ int ha_ndbcluster::add_index_handle(THD *thd, NDBDICT *dict, KEY *key_info,
/* /*
Associate index handles for each index of a table Associate index handles for each index of a table
*/ */
int ha_ndbcluster::open_indexes(Ndb *ndb, TABLE *tab) int ha_ndbcluster::open_indexes(Ndb *ndb, TABLE *tab, bool ignore_error)
{ {
uint i; uint i;
int error= 0; int error= 0;
...@@ -1263,6 +1264,9 @@ int ha_ndbcluster::open_indexes(Ndb *ndb, TABLE *tab) ...@@ -1263,6 +1264,9 @@ int ha_ndbcluster::open_indexes(Ndb *ndb, TABLE *tab)
for (i= 0; i < tab->s->keys; i++, key_info++, key_name++) for (i= 0; i < tab->s->keys; i++, key_info++, key_name++)
{ {
if ((error= add_index_handle(thd, dict, key_info, *key_name, i))) if ((error= add_index_handle(thd, dict, key_info, *key_name, i)))
if (ignore_error)
m_index[i].index= m_index[i].unique_index= NULL;
else
break; break;
} }
...@@ -3739,7 +3743,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) ...@@ -3739,7 +3743,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
{ {
m_table= (void *)tab; m_table= (void *)tab;
m_table_version = tab->getObjectVersion(); m_table_version = tab->getObjectVersion();
if (!(my_errno= open_indexes(ndb, table))) if (!(my_errno= open_indexes(ndb, table, FALSE)))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
m_table_info= tab_info; m_table_info= tab_info;
......
...@@ -691,6 +691,10 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -691,6 +691,10 @@ static void set_tabname(const char *pathname, char *tabname);
private: private:
friend int ndbcluster_drop_database_impl(const char *path); friend int ndbcluster_drop_database_impl(const char *path);
friend int ndb_handle_schema_change(THD *thd,
Ndb *ndb, NdbEventOperation *pOp,
NDB_SHARE *share);
int alter_table_name(const char *to); int alter_table_name(const char *to);
static int delete_table(ha_ndbcluster *h, Ndb *ndb, static int delete_table(ha_ndbcluster *h, Ndb *ndb,
const char *path, const char *path,
...@@ -708,7 +712,7 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -708,7 +712,7 @@ static void set_tabname(const char *pathname, char *tabname);
int create_indexes(Ndb *ndb, TABLE *tab); int create_indexes(Ndb *ndb, TABLE *tab);
void clear_index(int i); void clear_index(int i);
void clear_indexes(); void clear_indexes();
int open_indexes(Ndb *ndb, TABLE *tab); int open_indexes(Ndb *ndb, TABLE *tab, bool ignore_error);
void renumber_indexes(Ndb *ndb, TABLE *tab); void renumber_indexes(Ndb *ndb, TABLE *tab);
int drop_indexes(Ndb *ndb, TABLE *tab); int drop_indexes(Ndb *ndb, TABLE *tab);
int add_index_handle(THD *thd, NdbDictionary::Dictionary *dict, int add_index_handle(THD *thd, NdbDictionary::Dictionary *dict,
......
...@@ -1285,7 +1285,7 @@ ndbcluster_update_slock(THD *thd, ...@@ -1285,7 +1285,7 @@ ndbcluster_update_slock(THD *thd,
/* /*
Handle _non_ data events from the storage nodes Handle _non_ data events from the storage nodes
*/ */
static int int
ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
NDB_SHARE *share) NDB_SHARE *share)
{ {
...@@ -1294,12 +1294,18 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, ...@@ -1294,12 +1294,18 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
if (pOp->getEventType() != NDBEVENT::TE_CLUSTER_FAILURE && if (pOp->getEventType() != NDBEVENT::TE_CLUSTER_FAILURE &&
pOp->getReqNodeId() != g_ndb_cluster_connection->node_id()) pOp->getReqNodeId() != g_ndb_cluster_connection->node_id())
{ {
ndb->setDatabaseName(share->table->s->db.str); TABLE_SHARE *table_share= share->table->s;
ha_ndbcluster::invalidate_dictionary_cache(share->table->s, TABLE* table= share->table;
ndb,
share->table->s->db.str, /*
share->table->s->table_name.str, Invalidate table and all it's indexes
TRUE); */
ha_ndbcluster table_handler(table_share);
table_handler.set_dbname(share->key);
table_handler.set_tabname(share->key);
table_handler.open_indexes(ndb, table, TRUE);
table_handler.invalidate_dictionary_cache(TRUE);
remote_drop_table= 1; remote_drop_table= 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment