BUG #14612 If a restore is done on a slave cluster, yet the apply_status and...

BUG #14612 If a restore is done on a slave cluster, yet the apply_status and schema tables don't exist,
           ndb_restore tool should create them.
parent 01c02f34
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
virtual void logEntry(const LogEntry &){} virtual void logEntry(const LogEntry &){}
virtual void endOfLogEntrys(){} virtual void endOfLogEntrys(){}
virtual bool finalize_table(const TableS &){return true;} virtual bool finalize_table(const TableS &){return true;}
virtual bool createSystable(const TableS &){ return true;}
virtual bool update_apply_status(const RestoreMetaData &metaData){return true;} virtual bool update_apply_status(const RestoreMetaData &metaData){return true;}
NODE_GROUP_MAP *m_nodegroup_map; NODE_GROUP_MAP *m_nodegroup_map;
uint m_nodegroup_map_len; uint m_nodegroup_map_len;
......
...@@ -666,6 +666,33 @@ err: ...@@ -666,6 +666,33 @@ err:
return result; return result;
} }
bool
BackupRestore::createSystable(const TableS & tables){
const char *tablename = tables.getTableName();
if( strcmp(tablename, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0 &&
strcmp(tablename, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE) != 0 )
{
return true;
}
BaseString tmp(tablename);
Vector<BaseString> split;
if(tmp.split(split, "/") != 3){
err << "Invalid table name format " << tablename << endl;
return false;
}
m_ndb->setDatabaseName(split[0].c_str());
m_ndb->setSchemaName(split[1].c_str());
NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
if( dict->getTable(split[2].c_str()) != NULL ){
return true;
}
return table(tables);
}
bool bool
BackupRestore::table(const TableS & table){ BackupRestore::table(const TableS & table){
if (!m_restore && !m_restore_meta) if (!m_restore && !m_restore_meta)
......
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
virtual void endOfLogEntrys(); virtual void endOfLogEntrys();
virtual bool finalize_table(const TableS &); virtual bool finalize_table(const TableS &);
virtual bool has_temp_error(); virtual bool has_temp_error();
virtual bool createSystable(const TableS & table);
virtual bool update_apply_status(const RestoreMetaData &metaData); virtual bool update_apply_status(const RestoreMetaData &metaData);
void connectToMysql(); void connectToMysql();
bool map_in_frm(char *new_data, const char *data, bool map_in_frm(char *new_data, const char *data,
......
...@@ -567,6 +567,15 @@ main(int argc, char** argv) ...@@ -567,6 +567,15 @@ main(int argc, char** argv)
err << metaData[i]->getTableName() << " ... Exiting " << endl; err << metaData[i]->getTableName() << " ... Exiting " << endl;
exitHandler(NDBT_FAILED); exitHandler(NDBT_FAILED);
} }
} else {
for(Uint32 j= 0; j < g_consumers.size(); j++)
if (!g_consumers[j]->createSystable(* metaData[i]))
{
err << "Restore: Failed to restore system table: ";
err << metaData[i]->getTableName() << " ... Exiting " << endl;
exitHandler(NDBT_FAILED);
}
} }
} }
debug << "Close tables" << endl; debug << "Close tables" << endl;
......
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