diff options
author | unknown <jonas@eel.(none)> | 2005-08-18 14:02:25 +0200 |
---|---|---|
committer | unknown <jonas@eel.(none)> | 2005-08-18 14:02:25 +0200 |
commit | c7744c6df5c913f924fa02d0ec0ca6424105e336 (patch) | |
tree | 6f3c0b63f33e6dea6c70660522793c74ff935e53 /ndb | |
parent | c8cd901b33e7c4b757bb3977d7920a22710dd68e (diff) | |
download | mariadb-git-c7744c6df5c913f924fa02d0ec0ca6424105e336.tar.gz |
bug#12118 - ndb alter table data loss
Split table version into 2 (major, minor)
Impl. signaling to API when table has been altered
Allow running transactions to use any minor number for transactions
mysql-test/r/ndb_alter_table.result:
Allow running transactions to use old table definition when possible.
mysql-test/t/ndb_alter_table.test:
Allow running transactions to use old table definition when possible.
ndb/include/kernel/BlockNumbers.h:
remove GREP
ndb/include/kernel/GlobalSignalNumbers.h:
Add ALTER_TABL_REP and API_BROADCAST_REP
ndb/include/kernel/kernel_types.h:
table_version_major
ndb/include/kernel/signaldata/AlterTable.hpp:
New error code for alter table during rolling upgrade
ndb/include/ndbapi/NdbDictionary.hpp:
Add state on table object to represent an altered but still valid table object
ndb/src/common/debugger/BlockNames.cpp:
remove GREP
ndb/src/common/util/version.c:
Fix upgrades
ndb/src/kernel/SimBlockList.cpp:
remove GREP
ndb/src/kernel/blocks/Makefile.am:
remove GREP
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
remove GREP
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
Split tableSchemaVersion into 2 part
24 bit real version
8 bit for online alter table where old table definition is still usable
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
Check for same ndb versions
ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp:
Update schema printer
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
remove grep
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
1) Use table_ version_major when checking table version
2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/dbtc/Dbtc.hpp:
1) Use table_ version_major when checking table version
2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
1) Use table_ version_major when checking table version
2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp:
remove GREP
ndb/src/kernel/blocks/qmgr/Qmgr.hpp:
Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/qmgr/QmgrInit.cpp:
Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/qmgr/QmgrMain.cpp:
Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/suma/Suma.cpp:
remove GREP
ndb/src/mgmsrv/MgmtSrvr.cpp:
remove GREP
ndb/src/ndbapi/DictCache.cpp:
Add support for alter_table_rep
by setting status to Altered
NOTE special handling of tables in state RETREIVING
ndb/src/ndbapi/DictCache.hpp:
Add support for alter_table_rep
by setting status to Altered
NOTE special handling of tables in state RETREIVING
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Change alter table so that remove from global cache is used wo/ retreiving it from there first
as ALTER_TABLE_REP might already have changed the table object...
ndb/src/ndbapi/TransporterFacade.cpp:
Add support for ALTER_TABLE_REP
sql/ha_ndbcluster.cc:
Allow running transactions to use tables in state ALTERED...but new transactions may not...
ndb/include/kernel/signaldata/ApiBroadcast.hpp:
New BitKeeper file ``ndb/include/kernel/signaldata/ApiBroadcast.hpp''
Diffstat (limited to 'ndb')
28 files changed, 293 insertions, 121 deletions
diff --git a/ndb/include/kernel/BlockNumbers.h b/ndb/include/kernel/BlockNumbers.h index cb3cc697eee..49b5842ac4e 100644 --- a/ndb/include/kernel/BlockNumbers.h +++ b/ndb/include/kernel/BlockNumbers.h @@ -44,8 +44,7 @@ #define TRIX 0xFF #define DBUTIL 0x100 #define SUMA 0x101 -#define GREP 0x102 -#define DBTUX 0x103 +#define DBTUX 0x102 const BlockReference BACKUP_REF = numberToRef(BACKUP, 0); const BlockReference DBTC_REF = numberToRef(DBTC, 0); @@ -61,7 +60,6 @@ const BlockReference CMVMI_REF = numberToRef(CMVMI, 0); const BlockReference TRIX_REF = numberToRef(TRIX, 0); const BlockReference DBUTIL_REF = numberToRef(DBUTIL, 0); const BlockReference SUMA_REF = numberToRef(SUMA, 0); -const BlockReference GREP_REF = numberToRef(GREP, 0); const BlockReference DBTUX_REF = numberToRef(DBTUX, 0); const BlockNumber MIN_BLOCK_NO = BACKUP; diff --git a/ndb/include/kernel/GlobalSignalNumbers.h b/ndb/include/kernel/GlobalSignalNumbers.h index 9413f4ef56a..ff3690d60a5 100644 --- a/ndb/include/kernel/GlobalSignalNumbers.h +++ b/ndb/include/kernel/GlobalSignalNumbers.h @@ -777,8 +777,8 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES; /** * Grep signals */ -#define GSN_GREP_SUB_CREATE_REQ 606 -#define GSN_GREP_SUB_CREATE_REF 607 +#define GSN_ALTER_TABLE_REP 606 +#define GSN_API_BROADCAST_REP 607 #define GSN_GREP_SUB_CREATE_CONF 608 #define GSN_GREP_CREATE_REQ 609 #define GSN_GREP_CREATE_REF 610 diff --git a/ndb/include/kernel/kernel_types.h b/ndb/include/kernel/kernel_types.h index b176d20798c..e16e61471e7 100644 --- a/ndb/include/kernel/kernel_types.h +++ b/ndb/include/kernel/kernel_types.h @@ -36,6 +36,13 @@ enum Operation_t { #endif }; +inline +Uint32 +table_version_major(Uint32 ver) +{ + return ver & 0x00FFFFFF; +} + #endif diff --git a/ndb/include/kernel/signaldata/AlterTable.hpp b/ndb/include/kernel/signaldata/AlterTable.hpp index 173a9acf9ed..16c9eb204c9 100644 --- a/ndb/include/kernel/signaldata/AlterTable.hpp +++ b/ndb/include/kernel/signaldata/AlterTable.hpp @@ -129,7 +129,8 @@ public: InvalidPrimaryKeySize = 739, NullablePrimaryKey = 740, UnsupportedChange = 741, - BackupInProgress = 762 + BackupInProgress = 762, + IncompatibleVersions = 763 }; private: @@ -177,4 +178,26 @@ private: Uint32 tableVersion; }; +/** + * Inform API about change of table definition + */ +struct AlterTableRep +{ + friend bool printALTER_TABLE_REP(FILE*, const Uint32*, Uint32, Uint16); + + STATIC_CONST( SignalLength = 3 ); + + enum Change_type + { + CT_ALTERED = 0x1, + CT_DROPPED = 0x2 + }; + + Uint32 tableId; + Uint32 tableVersion; + Uint32 changeType; + + SECTION( TABLE_NAME = 0 ); +}; + #endif diff --git a/ndb/include/kernel/signaldata/ApiBroadcast.hpp b/ndb/include/kernel/signaldata/ApiBroadcast.hpp new file mode 100644 index 00000000000..8050326ce78 --- /dev/null +++ b/ndb/include/kernel/signaldata/ApiBroadcast.hpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef API_BROADCAST_HPP +#define API_BROADCAST_HPP + +#include "SignalData.hpp" + +struct ApiBroadcastRep +{ + STATIC_CONST( SignalLength = 2 ); + + Uint32 gsn; + Uint32 minVersion; + Uint32 theData[1]; +}; + +#endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 85615f3aa66..a541cd5190e 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -77,9 +77,10 @@ public: ///< changes to take effect Retrieved, ///< The object exist and has been read ///< into main memory from NDB Kernel - Invalid ///< The object has been invalidated + Invalid, ///< The object has been invalidated ///< and should not be used - + Altered ///< Table has been altered in NDB kernel + ///< but is still valid for usage }; /** diff --git a/ndb/src/common/debugger/BlockNames.cpp b/ndb/src/common/debugger/BlockNames.cpp index 44650b84c5c..0c61b6327ef 100644 --- a/ndb/src/common/debugger/BlockNames.cpp +++ b/ndb/src/common/debugger/BlockNames.cpp @@ -32,7 +32,6 @@ const BlockName BlockNames[] = { { "BACKUP", BACKUP }, { "DBUTIL", DBUTIL }, { "SUMA", SUMA }, - { "GREP", GREP }, { "DBTUX", DBTUX } }; diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c index 7221dc48fa4..05ce6d88d11 100644 --- a/ndb/src/common/util/version.c +++ b/ndb/src/common/util/version.c @@ -90,7 +90,8 @@ void ndbSetOwnVersion() {} #ifndef TEST_VERSION struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { - { MAKE_VERSION(4,1,NDB_VERSION_BUILD), MAKE_VERSION(4,1,10), UG_Range }, + { MAKE_VERSION(4,1,NDB_VERSION_BUILD), MAKE_VERSION(4,1,15), UG_Range }, + { MAKE_VERSION(4,1,14), MAKE_VERSION(4,1,10), UG_Range }, { MAKE_VERSION(4,1,10), MAKE_VERSION(4,1,9), UG_Exact }, { MAKE_VERSION(4,1,9), MAKE_VERSION(4,1,8), UG_Exact }, { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact }, @@ -98,6 +99,7 @@ struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { }; struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { + { MAKE_VERSION(4,1,15), MAKE_VERSION(4,1,14), UG_Exact }, { MAKE_VERSION(3,5,4), MAKE_VERSION(3,5,3), UG_Exact }, { 0, 0, UG_Null } }; diff --git a/ndb/src/kernel/SimBlockList.cpp b/ndb/src/kernel/SimBlockList.cpp index bf3958cf137..6029fc7e225 100644 --- a/ndb/src/kernel/SimBlockList.cpp +++ b/ndb/src/kernel/SimBlockList.cpp @@ -30,7 +30,6 @@ #include <Backup.hpp> #include <DbUtil.hpp> #include <Suma.hpp> -#include <Grep.hpp> #include <Dbtux.hpp> #include <NdbEnv.h> @@ -97,13 +96,14 @@ SimBlockList::load(const Configuration & conf){ theList[11] = NEW_BLOCK(Backup)(conf); theList[12] = NEW_BLOCK(DbUtil)(conf); theList[13] = NEW_BLOCK(Suma)(conf); - theList[14] = NEW_BLOCK(Grep)(conf); + theList[14] = 0; //NEW_BLOCK(Grep)(conf); theList[15] = NEW_BLOCK(Dbtux)(conf); // Metadata common part shared by block instances ptrMetaDataCommon = new MetaData::Common(*dbdict, *dbdih); for (int i = 0; i < noOfBlocks; i++) - theList[i]->setMetaDataCommon(ptrMetaDataCommon); + if(theList[i]) + theList[i]->setMetaDataCommon(ptrMetaDataCommon); } void diff --git a/ndb/src/kernel/blocks/Makefile.am b/ndb/src/kernel/blocks/Makefile.am index 7ee90e6239f..8addf257003 100644 --- a/ndb/src/kernel/blocks/Makefile.am +++ b/ndb/src/kernel/blocks/Makefile.am @@ -13,7 +13,6 @@ SUBDIRS = \ backup \ dbutil \ suma \ - grep \ dbtux windoze-dsp: diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 0274ef4af3e..7659ee1145d 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -987,7 +987,6 @@ Cmvmi::execDUMP_STATE_ORD(Signal* signal) sendSignal(BACKUP_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); sendSignal(DBUTIL_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); sendSignal(SUMA_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); - sendSignal(GREP_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); sendSignal(TRIX_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); sendSignal(DBTUX_REF, GSN_DUMP_STATE_ORD, signal, signal->length(), JBB); diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index a3ea195786e..f60720a1345 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -77,6 +77,7 @@ #include <signaldata/CreateFragmentation.hpp> #include <signaldata/CreateTab.hpp> #include <NdbSleep.h> +#include <signaldata/ApiBroadcast.hpp> #define ZNOT_FOUND 626 #define ZALREADYEXIST 630 @@ -91,6 +92,27 @@ #define DIV(x,y) (((x)+(y)-1)/(y)) #include <ndb_version.h> +static +Uint32 +alter_table_inc_schema_version(Uint32 old) +{ + return (old & 0x00FFFFFF) + ((old + 0x1000000) & 0xFF000000); +} + +static +Uint32 +alter_table_dec_schema_version(Uint32 old) +{ + return (old & 0x00FFFFFF) + ((old - 0x1000000) & 0xFF000000); +} + +static +Uint32 +create_table_inc_schema_version(Uint32 old) +{ + return (old + 0x00000001) & 0x00FFFFFF; +} + /* **************************************************************** */ /* ---------------------------------------------------------------- */ /* MODULE: GENERAL MODULE -------------------------------- */ @@ -584,7 +606,7 @@ void Dbdict::openTableFile(Signal* signal, jam(); fsOpenReq->fileFlags = FsOpenReq::OM_READONLY; }//if - ndbrequire(tablePtr.p->tableVersion < ZNIL); + fsOpenReq->fileNumber[3] = 0; // Initialise before byte changes FsOpenReq::setVersion(fsOpenReq->fileNumber, 1); FsOpenReq::setSuffix(fsOpenReq->fileNumber, FsOpenReq::S_TABLELIST); @@ -776,7 +798,7 @@ Dbdict::updateSchemaState(Signal* signal, Uint32 tableId, case SchemaFile::ADD_STARTED: jam(); ok = true; - ndbrequire((oldVersion + 1) == newVersion); + ndbrequire(create_table_inc_schema_version(oldVersion) == newVersion); ndbrequire(oldState == SchemaFile::INIT || oldState == SchemaFile::DROP_TABLE_COMMITTED); break; @@ -789,7 +811,7 @@ Dbdict::updateSchemaState(Signal* signal, Uint32 tableId, case SchemaFile::ALTER_TABLE_COMMITTED: jam(); ok = true; - ndbrequire((oldVersion + 1) == newVersion); + ndbrequire(alter_table_inc_schema_version(oldVersion) == newVersion); ndbrequire(oldState == SchemaFile::TABLE_ADD_COMMITTED || oldState == SchemaFile::ALTER_TABLE_COMMITTED); break; @@ -2806,6 +2828,21 @@ Dbdict::execBACKUP_FRAGMENT_REQ(Signal* signal) } } +bool +Dbdict::check_ndb_versions() const +{ + Uint32 node = 0; + Uint32 version = getNodeInfo(getOwnNodeId()).m_version; + while((node = c_aliveNodes.find(node + 1)) != BitmaskImpl::NotFound) + { + if(getNodeInfo(node).m_version != version) + { + return false; + } + } + return true; +} + void Dbdict::execALTER_TABLE_REQ(Signal* signal) { @@ -2842,6 +2879,13 @@ Dbdict::execALTER_TABLE_REQ(Signal* signal) alterTableRef(signal, req, AlterTableRef::Busy); return; } + + if (!check_ndb_versions()) + { + jam(); + alterTableRef(signal, req, AlterTableRef::IncompatibleVersions); + return; + } const TableRecord::TabState tabState = tablePtr.p->tabState; bool ok = false; @@ -2992,7 +3036,7 @@ Dbdict::alterTable_backup_mutex_locked(Signal* signal, lreq->clientData = alterTabPtr.p->m_senderData; lreq->changeMask = alterTabPtr.p->m_changeMask; lreq->tableId = tablePtr.p->tableId; - lreq->tableVersion = tablePtr.p->tableVersion + 1; + lreq->tableVersion = alter_table_inc_schema_version(tablePtr.p->tableVersion); lreq->gci = tablePtr.p->gciTableCreated; lreq->requestType = AlterTabReq::AlterTablePrepare; @@ -3072,6 +3116,14 @@ Dbdict::execALTER_TAB_REQ(Signal * signal) alterTabRef(signal, req, AlterTableRef::Busy); return; } + + if (!check_ndb_versions()) + { + jam(); + alterTabRef(signal, req, AlterTableRef::IncompatibleVersions); + return; + } + alterTabPtr.p->m_alterTableId = tableId; alterTabPtr.p->m_coordinatorRef = senderRef; @@ -3114,7 +3166,7 @@ Dbdict::execALTER_TAB_REQ(Signal * signal) } ndbrequire(ok); - if(tablePtr.p->tableVersion + 1 != tableVersion){ + if(alter_table_inc_schema_version(tablePtr.p->tableVersion) != tableVersion){ jam(); alterTabRef(signal, req, AlterTableRef::InvalidTableVersion); return; @@ -3599,7 +3651,7 @@ void Dbdict::revertAlterTable(Signal * signal, // Restore name strcpy(tablePtr.p->tableName, alterTabPtrP->previousTableName); // Revert schema version - tablePtr.p->tableVersion = tablePtr.p->tableVersion - 1; + tablePtr.p->tableVersion = alter_table_dec_schema_version(tablePtr.p->tableVersion); // Put it back #ifdef VM_TRACE ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p)); @@ -3659,6 +3711,27 @@ Dbdict::alterTab_writeTableConf(Signal* signal, conf->requestType = AlterTabReq::AlterTableCommit; sendSignal(coordinatorRef, GSN_ALTER_TAB_CONF, signal, AlterTabConf::SignalLength, JBB); + + + { + ApiBroadcastRep* api= (ApiBroadcastRep*)signal->getDataPtrSend(); + api->gsn = GSN_ALTER_TABLE_REP; + api->minVersion = MAKE_VERSION(4,1,15); + + AlterTableRep* rep = (AlterTableRep*)api->theData; + rep->tableId = tabPtr.p->tableId; + rep->tableVersion = alter_table_dec_schema_version(tabPtr.p->tableVersion); + rep->changeType = AlterTableRep::CT_ALTERED; + + LinearSectionPtr ptr[3]; + ptr[0].p = (Uint32*)alterTabPtr.p->previousTableName; + ptr[0].sz = (sizeof(alterTabPtr.p->previousTableName) + 3) >> 2; + + sendSignal(QMGR_REF, GSN_API_BROADCAST_REP, signal, + ApiBroadcastRep::SignalLength + AlterTableRep::SignalLength, + JBB, ptr,1); + } + if(coordinatorRef != reference()) { jam(); // Release resources @@ -3711,7 +3784,7 @@ Dbdict::execCREATE_FRAGMENTATION_CONF(Signal* signal){ c_pageRecordArray.getPtr(pagePtr, c_schemaRecord.schemaPage); SchemaFile::TableEntry * tabEntry = getTableEntry(pagePtr.p, tabPtr.i); - tabPtr.p->tableVersion = tabEntry->m_tableVersion + 1; + tabPtr.p->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion); /** * Pack @@ -3740,7 +3813,7 @@ Dbdict::execCREATE_FRAGMENTATION_CONF(Signal* signal){ req->gci = 0; req->tableId = tabPtr.i; - req->tableVersion = tabEntry->m_tableVersion + 1; + req->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion); sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal, CreateTabReq::SignalLength, JBB); diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 48dc2d2c2d5..77a44d0ad24 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -578,6 +578,7 @@ private: void execALTER_TAB_REQ(Signal* signal); void execALTER_TAB_REF(Signal* signal); void execALTER_TAB_CONF(Signal* signal); + bool check_ndb_versions() const; /* * 2.4 COMMON STORED VARIABLES diff --git a/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp index 0ba52878b7c..3e944485e1c 100644 --- a/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp +++ b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp @@ -58,7 +58,8 @@ print(const char * filename, const SchemaFile * file){ SchemaFile::TableEntry te = file->TableEntries[i]; if(te.m_tableState != SchemaFile::INIT){ ndbout << "Table " << i << ": State = " << te.m_tableState - << " version = " << te.m_tableVersion + << " version = " << table_version_major(te.m_tableVersion) << + << "(" << table_version_minor(te.m_tableVersion) << ")" << " type = " << te.m_tableType << " noOfPages = " << te.m_noOfPages << " gcp: " << te.m_gcp << endl; diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 82678827927..94426c8be3f 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -1886,8 +1886,6 @@ void Dbdih::execINCL_NODECONF(Signal* signal) // Suma will not send response to this for now, later... sendSignal(SUMA_REF, GSN_INCL_NODEREQ, signal, 2, JBB); - // Grep will not send response to this for now, later... - sendSignal(GREP_REF, GSN_INCL_NODEREQ, signal, 2, JBB); return; }//if if (TstartNode_or_blockref == numberToRef(BACKUP, getOwnNodeId())){ diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 5d689274f26..05d76f5fb25 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -3512,7 +3512,8 @@ void Dblqh::execLQHKEYREQ(Signal* signal) LQHKEY_abort(signal, 4); return; } - if(tabptr.p->schemaVersion != schemaVersion){ + if(table_version_major(tabptr.p->schemaVersion) != + table_version_major(schemaVersion)){ LQHKEY_abort(signal, 5); return; } @@ -4451,7 +4452,7 @@ void Dblqh::packLqhkeyreqLab(Signal* signal) lqhKeyReq->requestInfo = Treqinfo; lqhKeyReq->tcBlockref = sig4; - sig0 = regTcPtr->tableref + (regTcPtr->schemaVersion << 16); + sig0 = regTcPtr->tableref + ((regTcPtr->schemaVersion << 16) & 0xFFFF0000); sig1 = regTcPtr->fragmentid + (regTcPtr->nodeAfterNext[0] << 16); sig2 = regTcPtr->transid[0]; sig3 = regTcPtr->transid[1]; @@ -15840,7 +15841,7 @@ Uint32 Dblqh::checkIfExecLog(Signal* signal) tabptr.i = tcConnectptr.p->tableref; ptrCheckGuard(tabptr, ctabrecFileSize, tablerec); if (getFragmentrec(signal, tcConnectptr.p->fragmentid) && - (tabptr.p->schemaVersion == tcConnectptr.p->schemaVersion)) { + (table_version_major(tabptr.p->schemaVersion) == table_version_major(tcConnectptr.p->schemaVersion))) { if (fragptr.p->execSrStatus != Fragrecord::IDLE) { if (fragptr.p->execSrNoReplicas > logPartPtr.p->execSrExecuteIndex) { ndbrequire((fragptr.p->execSrNoReplicas - 1) < 4); diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index fbd181cae24..61afef30b43 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -958,7 +958,8 @@ public: Uint8 storedTable; bool checkTable(Uint32 schemaVersion) const { - return enabled && !dropping && (schemaVersion == currentSchemaVersion); + return enabled && !dropping && + (table_version_major(schemaVersion) == table_version_major(currentSchemaVersion)); } Uint32 getErrorCode(Uint32 schemaVersion) const; diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 736a660f396..93b122b9a99 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -3196,7 +3196,7 @@ void Dbtc::sendlqhkeyreq(Signal* signal, lqhKeyReq->tcBlockref = sig4; lqhKeyReq->savePointId = sig5; - sig0 = regCachePtr->tableref + (regCachePtr->schemaVersion << 16); + sig0 = regCachePtr->tableref + ((regCachePtr->schemaVersion << 16) & 0xFFFF0000); sig1 = regCachePtr->fragmentid + (regTcPtr->tcNodedata[1] << 16); sig2 = regApiPtr->transid[0]; sig3 = regApiPtr->transid[1]; @@ -12877,7 +12877,7 @@ Dbtc::TableRecord::getErrorCode(Uint32 schemaVersion) const { return ZNO_SUCH_TABLE; if(dropping) return ZDROP_TABLE_IN_PROGRESS; - if(schemaVersion != currentSchemaVersion) + if(table_version_major(schemaVersion) != table_version_major(currentSchemaVersion)) return ZWRONG_SCHEMA_VERSION_ERROR; ErrorReporter::handleAssert("Dbtc::TableRecord::getErrorCode", __FILE__, __LINE__); diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 9eaa203b098..c80891548cf 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -76,7 +76,6 @@ static BlockInfo ALL_BLOCKS[] = { { BACKUP_REF, 1 , 10000, 10999 }, { DBUTIL_REF, 1 , 11000, 11999 }, { SUMA_REF, 1 , 13000, 13999 }, - { GREP_REF, 1 , 0, 0 }, { DBTUX_REF, 1 , 12000, 12999 } }; @@ -1453,9 +1452,6 @@ void Ndbcntr::execNODE_FAILREP(Signal* signal) sendSignal(SUMA_REF, GSN_NODE_FAILREP, signal, NodeFailRep::SignalLength, JBB); - sendSignal(GREP_REF, GSN_NODE_FAILREP, signal, - NodeFailRep::SignalLength, JBB); - Uint32 nodeId = 0; while(!allFailed.isclear()){ nodeId = allFailed.find(nodeId + 1); @@ -2381,7 +2377,6 @@ void Ndbcntr::execREAD_CONFIG_CONF(Signal* signal){ void Ndbcntr::execSTART_ORD(Signal* signal){ jamEntry(); - ndbrequire(NO_OF_BLOCKS == ALL_BLOCKS_SZ); c_missra.execSTART_ORD(signal); } @@ -2456,7 +2451,7 @@ void Ndbcntr::Missra::sendNextREAD_CONFIG_REQ(Signal* signal){ * Finished... */ currentStartPhase = 0; - for(Uint32 i = 0; i<NO_OF_BLOCKS; i++){ + for(Uint32 i = 0; i<ALL_BLOCKS_SZ; i++){ if(ALL_BLOCKS[i].NextSP < currentStartPhase) currentStartPhase = ALL_BLOCKS[i].NextSP; } diff --git a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp index 0ff7cea6d9f..20f5aacb530 100644 --- a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp +++ b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp @@ -220,6 +220,7 @@ private: void execAPI_VERSION_REQ(Signal* signal); + void execAPI_BROADCAST_REP(Signal* signal); // Arbitration signals void execARBIT_CFG(Signal* signal); diff --git a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp index d6960ce154e..43d8f0971ed 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp @@ -80,7 +80,8 @@ Qmgr::Qmgr(const class Configuration & conf) addRecSignal(GSN_API_FAILCONF, &Qmgr::execAPI_FAILCONF); addRecSignal(GSN_READ_NODESREQ, &Qmgr::execREAD_NODESREQ); addRecSignal(GSN_SET_VAR_REQ, &Qmgr::execSET_VAR_REQ); - + addRecSignal(GSN_API_BROADCAST_REP, &Qmgr::execAPI_BROADCAST_REP); + // Arbitration signals addRecSignal(GSN_ARBIT_PREPREQ, &Qmgr::execARBIT_PREPREQ); addRecSignal(GSN_ARBIT_PREPCONF, &Qmgr::execARBIT_PREPCONF); diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index da8596076ec..0e3975439b9 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -34,6 +34,7 @@ #include <signaldata/BlockCommitOrd.hpp> #include <signaldata/FailRep.hpp> #include <signaldata/DisconnectRep.hpp> +#include <signaldata/ApiBroadcast.hpp> #include <ndb_version.h> @@ -1702,16 +1703,6 @@ void Qmgr::sendApiFailReq(Signal* signal, Uint16 failedNodeNo) sendSignal(DBDICT_REF, GSN_API_FAILREQ, signal, 2, JBA); sendSignal(SUMA_REF, GSN_API_FAILREQ, signal, 2, JBA); - /** - * GREP also need the information that an API node - * (actually a REP node) has failed. - * - * GREP does however NOT send a CONF on this signal, i.e. - * the API_FAILREQ signal to GREP is like a REP signal - * (i.e. without any confirmation). - */ - sendSignal(GREP_REF, GSN_API_FAILREQ, signal, 2, JBA); - /**------------------------------------------------------------------------- * THE OTHER NODE WAS AN API NODE. THE COMMUNICATION LINK IS ALREADY * BROKEN AND THUS NO ACTION IS NEEDED TO BREAK THE CONNECTION. @@ -3926,3 +3917,30 @@ void Qmgr::execSET_VAR_REQ(Signal* signal) }// switch #endif }//execSET_VAR_REQ() + +void +Qmgr::execAPI_BROADCAST_REP(Signal* signal) +{ + jamEntry(); + ApiBroadcastRep api= *(const ApiBroadcastRep*)signal->getDataPtr(); + + Uint32 len = signal->getLength() - ApiBroadcastRep::SignalLength; + memmove(signal->theData, signal->theData+ApiBroadcastRep::SignalLength, + 4*len); + + NodeBitmask mask; + NodeRecPtr nodePtr; + for (nodePtr.i = 1; nodePtr.i < MAX_NODES; nodePtr.i++) + { + jam(); + ptrAss(nodePtr, nodeRec); + if (nodePtr.p->phase == ZAPI_ACTIVE && + getNodeInfo(nodePtr.i).m_version >= api.minVersion) + { + mask.set(nodePtr.i); + } + } + + NodeReceiverGroup rg(API_CLUSTERMGR, mask); + sendSignal(rg, api.gsn, signal, len, JBB); // forward sections +} diff --git a/ndb/src/kernel/blocks/suma/Suma.cpp b/ndb/src/kernel/blocks/suma/Suma.cpp index 44ac054dd67..84a59f440d9 100644 --- a/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/ndb/src/kernel/blocks/suma/Suma.cpp @@ -2143,7 +2143,8 @@ SumaParticipant::execSUB_START_REQ(Signal* signal){ case SubCreateReq::DatabaseSnapshot: case SubCreateReq::SelectiveTableSnapshot: jam(); - subbPtr.p->m_subscriberRef = GREP_REF; + ndbrequire(false); + //subbPtr.p->m_subscriberRef = GREP_REF; subbPtr.p->m_subscriberData = subPtr.p->m_subscriberData; break; case SubCreateReq::SingleTableScan: @@ -2972,16 +2973,6 @@ SumaParticipant::execSUB_GCP_COMPLETE_REP(Signal* signal){ c_lastCompleteGCI = gci; /** - * always send SUB_GCP_COMPLETE_REP to Grep (so - * Lars can do funky stuff calculating intervals, - * even before the subscription is started - */ - rep->senderRef = reference(); - rep->senderData = 0; //ignored in grep - EXECUTE_DIRECT(refToBlock(GREP_REF), GSN_SUB_GCP_COMPLETE_REP, signal, - SubGcpCompleteRep::SignalLength); - - /** * Signal to subscriber(s) */ @@ -3005,13 +2996,6 @@ SumaParticipant::execSUB_GCP_COMPLETE_REP(Signal* signal){ ndbout_c("GSN_SUB_GCP_COMPLETE_REP to %s:", getBlockName(refToBlock(ref))); #else - /** - * Ignore sending to GREP (since we sent earlier) - */ - if (ref == GREP_REF) { - jam(); - continue; - } CRASH_INSERTION(13018); diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index ceaedc9955b..292e13a234b 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2541,44 +2541,7 @@ MgmtSrvr::backupCallback(BackupEvent & event) int MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted) { - bool next; - NodeId nodeId = 0; - - while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true && - theFacade->get_node_alive(nodeId) == false); - - if(!next){ - return NO_CONTACT_WITH_DB_NODES; - } - - NdbApiSignal* signal = getSignal(); - if (signal == NULL) { - return COULD_NOT_ALLOCATE_MEMORY; - } - - GrepReq* req = CAST_PTR(GrepReq, signal->getDataPtrSend()); - signal->set(TestOrd::TraceAPI, GREP, GSN_GREP_REQ, GrepReq::SignalLength); - req->senderRef = _ownReference; - req->request = request; - - int result; - if (waitCompleted) - result = sendRecSignal(nodeId, NO_WAIT, signal, true); - else - result = sendRecSignal(nodeId, NO_WAIT, signal, true); - if (result == -1) { - return SEND_OR_RECEIVE_FAILED; - } - - /** - * @todo - * Maybe add that we should receive a confirmation that the - * request was received ok. - * Then we should give the user the correct repReqId. - */ - - *repReqId = 4711; - + abort(); return 0; } diff --git a/ndb/src/ndbapi/DictCache.cpp b/ndb/src/ndbapi/DictCache.cpp index ccc45a04824..ca361e900b1 100644 --- a/ndb/src/ndbapi/DictCache.cpp +++ b/ndb/src/ndbapi/DictCache.cpp @@ -21,6 +21,9 @@ #include <NdbCondition.h> #include <NdbSleep.h> +static NdbTableImpl f_invalid_table; +static NdbTableImpl f_altered_table; + Ndb_local_table_info * Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz) { @@ -164,21 +167,41 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) TableVersion & ver = vers->back(); if(ver.m_status != RETREIVING || - ver.m_impl != 0 || + !(ver.m_impl == 0 || + ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || ver.m_version != 0 || ver.m_refCount == 0){ abort(); } - if(tab == 0){ + if(tab == 0) + { // No table found in db vers->erase(sz - 1); - } else { + } + else if (ver.m_impl == 0) { ver.m_impl = tab; ver.m_version = tab->m_version; ver.m_status = OK; + } + else if (ver.m_impl == &f_invalid_table) + { + ver.m_impl = tab; + ver.m_version = tab->m_version; + ver.m_status = DROPPED; + ver.m_impl->m_status = NdbDictionary::Object::Invalid; + } + else if(ver.m_impl == &f_altered_table) + { + ver.m_impl = tab; + ver.m_version = tab->m_version; + ver.m_status = DROPPED; + ver.m_impl->m_status = NdbDictionary::Object::Altered; + } + else + { + abort(); } - NdbCondition_Broadcast(m_waitForTableCondition); return tab; } @@ -275,4 +298,45 @@ GlobalDictCache::release(NdbTableImpl * tab){ abort(); } +void +GlobalDictCache::alter_table_rep(const char * name, + Uint32 tableId, + Uint32 tableVersion, + bool altered) +{ + const Uint32 len = strlen(name); + Vector<TableVersion> * vers = + m_tableHash.getData(name, len); + + if(vers == 0) + { + return; + } + + const Uint32 sz = vers->size(); + if(sz == 0) + { + return; + } + + for(Uint32 i = 0; i < sz; i++) + { + TableVersion & ver = (* vers)[i]; + if(ver.m_version == tableVersion && ver.m_impl && + ver.m_impl->m_tableId == tableId) + { + ver.m_status = DROPPED; + ver.m_impl->m_status = altered ? + NdbDictionary::Object::Altered : NdbDictionary::Object::Invalid; + return; + } + + if(i == sz - 1 && ver.m_status == RETREIVING) + { + ver.m_impl = altered ? &f_altered_table : &f_invalid_table; + return; + } + } +} + template class Vector<GlobalDictCache::TableVersion>; diff --git a/ndb/src/ndbapi/DictCache.hpp b/ndb/src/ndbapi/DictCache.hpp index ca31c345396..7f2ee457476 100644 --- a/ndb/src/ndbapi/DictCache.hpp +++ b/ndb/src/ndbapi/DictCache.hpp @@ -68,6 +68,9 @@ public: NdbTableImpl* put(const char * name, NdbTableImpl *); void drop(NdbTableImpl *); void release(NdbTableImpl *); + + void alter_table_rep(const char * name, + Uint32 tableId, Uint32 tableVersion, bool altered); public: enum Status { OK = 0, diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 27fd70cd0f4..8b1847502d9 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1439,25 +1439,22 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) const char * originalExternalName = externalName.c_str(); DBUG_ENTER("NdbDictionaryImpl::alterTable"); - if(!get_local_table_info(originalInternalName, false)){ + Ndb_local_table_info * local = 0; + if((local= get_local_table_info(originalInternalName, false)) == 0) + { m_error.code = 709; DBUG_RETURN(-1); } + // Alter the table int ret = m_receiver.alterTable(m_ndb, impl); if(ret == 0){ // Remove cached information and let it be refreshed at next access - if (m_localHash.get(originalInternalName) != NULL) { - m_localHash.drop(originalInternalName); - m_globalHash->lock(); - NdbTableImpl * cachedImpl = m_globalHash->get(originalInternalName); - // If in local cache it must be in global - if (!cachedImpl) - abort(); - cachedImpl->m_status = NdbDictionary::Object::Invalid; - m_globalHash->drop(cachedImpl); - m_globalHash->unlock(); - } + m_globalHash->lock(); + local->m_table_impl->m_status = NdbDictionary::Object::Invalid; + m_globalHash->drop(local->m_table_impl); + m_globalHash->unlock(); + m_localHash.drop(originalInternalName); } DBUG_RETURN(ret); } diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 93cec59ada6..a89b6287872 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -35,6 +35,7 @@ #include <ndb_version.h> #include <SignalLoggerManager.hpp> #include <kernel/ndb_limits.h> +#include <signaldata/AlterTable.hpp> //#define REPORT_TRANSPORTER //#define API_TRACE; @@ -305,6 +306,17 @@ execute(void * callbackObj, SignalHeader * const header, theFacade->theArbitMgr->doStop(theData); break; + case GSN_ALTER_TABLE_REP: + { + const AlterTableRep* rep = (const AlterTableRep*)theData; + theFacade->m_globalDictCache.lock(); + theFacade->m_globalDictCache. + alter_table_rep((const char*)ptr[0].p, + rep->tableId, + rep->tableVersion, + rep->changeType == AlterTableRep::CT_ALTERED); + theFacade->m_globalDictCache.unlock(); + } default: break; |