3653 jonas oreland 2011-11-18 [merge]
ndb - merge 71 to 72
added:
storage/ndb/src/kernel/blocks/trpman.cpp
storage/ndb/src/kernel/blocks/trpman.hpp
modified:
scripts/mysql_system_tables.sql
storage/ndb/include/kernel/ndb_limits.h
storage/ndb/src/common/debugger/EventLogger.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
storage/ndb/src/kernel/ndbd.cpp
storage/ndb/src/kernel/vm/Ndbinfo.hpp
storage/ndb/tools/ndbinfo_sql.cpp
3652 Martin Skold 2011-11-17
Fixed incorrect merge
modified:
mysql-test/suite/ndb/r/ndb_condition_pushdown.result
mysql-test/suite/ndb/t/ndb_condition_pushdown.test
=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql 2011-11-03 17:22:01 +0000
+++ b/scripts/mysql_system_tables.sql 2011-11-18 06:47:23 +0000
@@ -857,7 +857,7 @@ EXECUTE stmt;
DROP PREPARE stmt;
# ndbinfo.counters
-SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`counters` AS SELECT node_id, b.block_name, block_instance, counter_id, CASE counter_id WHEN 1 THEN "ATTRINFO" WHEN 2 THEN "TRANSACTIONS" WHEN 3 THEN "COMMITS" WHEN 4 THEN "READS" WHEN 5 THEN "SIMPLE_READS" WHEN 6 THEN "WRITES" WHEN 7 THEN "ABORTS" WHEN 8 THEN "TABLE_SCANS" WHEN 9 THEN "RANGE_SCANS" WHEN 10 THEN "OPERATIONS" WHEN 11 THEN "READS_RECEIVED" WHEN 12 THEN "LOCAL_READS_SENT" WHEN 13 THEN "REMOTE_READS_SENT" WHEN 14 THEN "READS_NOT_FOUND" WHEN 15 THEN "TABLE_SCANS_RECEIVED" WHEN 16 THEN "LOCAL_TABLE_SCANS_SENT" WHEN 17 THEN "RANGE_SCANS_RECEIVED" WHEN 18 THEN "LOCAL_RANGE_SCANS_SENT" WHEN 19 THEN "REMOTE_RANGE_SCANS_SENT" WHEN 20 THEN "SCAN_BATCHES_RETURNED" WHEN 21 THEN "SCAN_ROWS_RETURNED" WHEN 22 THEN "PRUNED_RANGE_SCANS_RECEIVED" WHEN 23 THEN "CONST_PRUNED_RANGE_SCANS_RECEIVED" ELSE "<unknown>" END AS counter_name, val FROM `ndbinfo
`.`ndb$counters` c LEFT JOIN `ndbinfo`.blocks b ON c.block_number = b.block_number','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`counters` AS SELECT node_id, b.block_name, block_instance, counter_id, CASE counter_id WHEN 1 THEN "ATTRINFO" WHEN 2 THEN "TRANSACTIONS" WHEN 3 THEN "COMMITS" WHEN 4 THEN "READS" WHEN 5 THEN "SIMPLE_READS" WHEN 6 THEN "WRITES" WHEN 7 THEN "ABORTS" WHEN 8 THEN "TABLE_SCANS" WHEN 9 THEN "RANGE_SCANS" WHEN 10 THEN "OPERATIONS" WHEN 11 THEN "READS_RECEIVED" WHEN 12 THEN "LOCAL_READS_SENT" WHEN 13 THEN "REMOTE_READS_SENT" WHEN 14 THEN "READS_NOT_FOUND" WHEN 15 THEN "TABLE_SCANS_RECEIVED" WHEN 16 THEN "LOCAL_TABLE_SCANS_SENT" WHEN 17 THEN "RANGE_SCANS_RECEIVED" WHEN 18 THEN "LOCAL_RANGE_SCANS_SENT" WHEN 19 THEN "REMOTE_RANGE_SCANS_SENT" WHEN 20 THEN "SCAN_BATCHES_RETURNED" WHEN 21 THEN "SCAN_ROWS_RETURNED" WHEN 22 THEN "PRUNED_RANGE_SCANS_RECEIVED" WHEN 23 THEN "CONST_PRUNED_RANGE_SCANS_RECEIVED" WHEN 24 THEN "LOCAL_READS" ELSE "<unknown>" END AS cou
nter_name, val FROM `ndbinfo`.`ndb$counters` c LEFT JOIN `ndbinfo`.blocks b ON c.block_number = b.block_number','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
=== modified file 'storage/ndb/include/kernel/ndb_limits.h'
--- a/storage/ndb/include/kernel/ndb_limits.h 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/include/kernel/ndb_limits.h 2011-11-18 06:47:23 +0000
@@ -194,6 +194,7 @@
#define NDBMT_BLOCK_MASK ((1 << NDBMT_BLOCK_BITS) - 1)
#define NDBMT_BLOCK_INSTANCE_BITS 7
+#define NDB_DEFAULT_LOG_PARTS 4
#define NDB_MAX_LOG_PARTS 4
#define MAX_NDBMT_LQH_WORKERS NDB_MAX_LOG_PARTS
#define MAX_NDBMT_LQH_THREADS NDB_MAX_LOG_PARTS
=== modified file 'storage/ndb/src/common/debugger/EventLogger.cpp'
--- a/storage/ndb/src/common/debugger/EventLogger.cpp 2011-10-21 12:36:44 +0000
+++ b/storage/ndb/src/common/debugger/EventLogger.cpp 2011-11-18 06:47:23 +0000
@@ -527,23 +527,47 @@ void getTextTransReportCounters(QQQQ) {
// -------------------------------------------------------------------
// Report information about transaction activity once per 10 seconds.
// -------------------------------------------------------------------
- BaseString::snprintf(m_text, m_text_len,
- "Trans. Count = %u, Commit Count = %u, "
- "Read Count = %u, Simple Read Count = %u, "
- "Write Count = %u, AttrInfo Count = %u, "
- "Concurrent Operations = %u, Abort Count = %u"
- " Scans = %u Range scans = %u",
- theData[1],
- theData[2],
- theData[3],
- theData[4],
- theData[5],
- theData[6],
- theData[7],
- theData[8],
- theData[9],
- theData[10]);
+ if (len <= 11)
+ {
+ BaseString::snprintf(m_text, m_text_len,
+ "Trans. Count = %u, Commit Count = %u, "
+ "Read Count = %u, Simple Read Count = %u, "
+ "Write Count = %u, AttrInfo Count = %u, "
+ "Concurrent Operations = %u, Abort Count = %u"
+ " Scans = %u Range scans = %u",
+ theData[1],
+ theData[2],
+ theData[3],
+ theData[4],
+ theData[5],
+ theData[6],
+ theData[7],
+ theData[8],
+ theData[9],
+ theData[10]);
+ }
+ else
+ {
+ BaseString::snprintf(m_text, m_text_len,
+ "Trans. Count = %u, Commit Count = %u, "
+ "Read Count = %u, Simple Read Count = %u, "
+ "Write Count = %u, AttrInfo Count = %u, "
+ "Concurrent Operations = %u, Abort Count = %u"
+ " Scans = %u Range scans = %u, Local Read Count = %u",
+ theData[1],
+ theData[2],
+ theData[3],
+ theData[4],
+ theData[5],
+ theData[6],
+ theData[7],
+ theData[8],
+ theData[9],
+ theData[10],
+ theData[11]);
+ }
}
+
void getTextOperationReportCounters(QQQQ) {
BaseString::snprintf(m_text, m_text_len,
"Operations=%u",
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2011-11-18 06:47:23 +0000
@@ -207,7 +207,8 @@ Dbdict::execDUMP_STATE_ORD(Signal* signa
const Uint32 tab = signal->theData[1];
const Uint32 ver = signal->theData[2];
TableRecordPtr tabRecPtr;
- c_tableRecordPool.getPtr(tabRecPtr, tab);
+ bool ok = find_object(tabRecPtr, tab);
+ ndbrequire(ok);
DropTableReq * req = (DropTableReq*)signal->getDataPtr();
req->senderData = 1225;
req->senderRef = numberToRef(1,1);
@@ -512,8 +513,8 @@ void Dbdict::packTableIntoPages(Signal*
case DictTabInfo::OrderedIndex:{
jam();
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
- if (tablePtr.p->m_obj_ptr_i == RNIL)
+ bool ok = find_object(tablePtr, tableId);
+ if (!ok)
{
jam();
sendGET_TABINFOREF(signal, &req_copy,
@@ -698,7 +699,15 @@ Dbdict::packTableIntoPages(SimplePropert
{
jam();
TableRecordPtr primTab;
- c_tableRecordPool.getPtr(primTab, tablePtr.p->primaryTableId);
+ bool ok = find_object(primTab, tablePtr.p->primaryTableId);
+ if (!ok)
+ {
+ jam();
+ ndbrequire(signal != NULL);
+ Uint32 err = CreateFragmentationRef::InvalidPrimaryTable;
+ signal->theData[0] = err;
+ return;
+ }
ConstRope r2(c_rope_pool, primTab.p->tableName);
r2.copy(tableName);
w.add(DictTabInfo::PrimaryTable, tableName);
@@ -893,8 +902,6 @@ Dbdict::execCREATE_FRAGMENTATION_REQ(Sig
return;
}
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, req->primaryTableId);
XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
SchemaFile::TableEntry * te = getTableEntry(xsf, req->primaryTableId);
if (te->m_tableState != SchemaFile::SF_CREATE)
@@ -911,8 +918,9 @@ Dbdict::execCREATE_FRAGMENTATION_REQ(Sig
}
DictObjectPtr obj_ptr;
- c_obj_pool.getPtr(obj_ptr, tablePtr.p->m_obj_ptr_i);
-
+ TableRecordPtr tablePtr;
+ bool ok = find_object(obj_ptr, tablePtr, req->primaryTableId);
+ ndbrequire(ok);
SchemaOpPtr op_ptr;
findDictObjectOp(op_ptr, obj_ptr);
ndbrequire(!op_ptr.isNull());
@@ -2233,8 +2241,6 @@ void Dbdict::initRecords()
{
initNodeRecords();
initPageRecords();
- initTableRecords();
- initTriggerRecords();
}//Dbdict::initRecords()
void Dbdict::initSendSchemaRecord()
@@ -2315,27 +2321,12 @@ void Dbdict::initPageRecords()
c_schemaRecord.oldSchemaPage = NDB_SF_MAX_PAGES;
}//Dbdict::initPageRecords()
-void Dbdict::initTableRecords()
-{
- TableRecordPtr tablePtr;
- while (1) {
- jam();
- refresh_watch_dog();
- c_tableRecordPool.seize(tablePtr);
- if (tablePtr.i == RNIL) {
- jam();
- break;
- }//if
- initialiseTableRecord(tablePtr);
- }//while
-}//Dbdict::initTableRecords()
-
-void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr)
+void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr, Uint32 tableId)
{
new (tablePtr.p) TableRecord();
tablePtr.p->filePtr[0] = RNIL;
tablePtr.p->filePtr[1] = RNIL;
- tablePtr.p->tableId = tablePtr.i;
+ tablePtr.p->tableId = tableId;
tablePtr.p->tableVersion = (Uint32)-1;
tablePtr.p->fragmentType = DictTabInfo::AllNodesSmallTable;
tablePtr.p->gciTableCreated = 0;
@@ -2375,29 +2366,15 @@ void Dbdict::initialiseTableRecord(Table
tablePtr.p->m_obj_ptr_i = RNIL;
}//Dbdict::initialiseTableRecord()
-void Dbdict::initTriggerRecords()
-{
- TriggerRecordPtr triggerPtr;
- while (1) {
- jam();
- refresh_watch_dog();
- c_triggerRecordPool.seize(triggerPtr);
- if (triggerPtr.i == RNIL) {
- jam();
- break;
- }//if
- initialiseTriggerRecord(triggerPtr);
- }//while
-}
-
-void Dbdict::initialiseTriggerRecord(TriggerRecordPtr triggerPtr)
+void Dbdict::initialiseTriggerRecord(TriggerRecordPtr triggerPtr, Uint32 triggerId)
{
new (triggerPtr.p) TriggerRecord();
triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
- triggerPtr.p->triggerId = RNIL;
+ triggerPtr.p->triggerId = triggerId;
triggerPtr.p->tableId = RNIL;
triggerPtr.p->attributeMask.clear();
triggerPtr.p->indexId = RNIL;
+ triggerPtr.p->m_obj_ptr_i = RNIL;
}
Uint32 Dbdict::getFsConnRecord()
@@ -2438,40 +2415,81 @@ Uint32 Dbdict::getFreeObjId(bool both)
return RNIL;
}
-Uint32 Dbdict::getFreeTableRecord()
+bool Dbdict::seizeTableRecord(TableRecordPtr& tablePtr, Uint32& schemaFileId)
{
- Uint32 i = getFreeObjId();
- if (i == RNIL) {
+ if (schemaFileId == RNIL)
+ {
jam();
- return RNIL;
+ schemaFileId = getFreeObjId();
}
- if (i >= c_noOfMetaTables) {
+ if (schemaFileId == RNIL)
+ {
jam();
- return RNIL;
+ return false;
+ }
+ if (schemaFileId >= c_noOfMetaTables)
+ {
+ jam();
+ return false;
}
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, i);
- initialiseTableRecord(tablePtr);
- return i;
+ c_tableRecordPool.seize(tablePtr);
+ if (tablePtr.isNull())
+ {
+ jam();
+ return false;
+ }
+ initialiseTableRecord(tablePtr, schemaFileId);
+ return true;
}
Uint32 Dbdict::getFreeTriggerRecord()
{
const Uint32 size = c_triggerRecordPool.getSize();
TriggerRecordPtr triggerPtr;
- for (triggerPtr.i = 0; triggerPtr.i < size; triggerPtr.i++) {
+ for (Uint32 id = 0; id < size; id++) {
jam();
- c_triggerRecordPool.getPtr(triggerPtr);
- if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED) {
+ bool ok = find_object(triggerPtr, id);
+ if (!ok)
+ {
jam();
- initialiseTriggerRecord(triggerPtr);
- return triggerPtr.i;
+ return id;
}
}
return RNIL;
}
+bool Dbdict::seizeTriggerRecord(TriggerRecordPtr& triggerPtr, Uint32 triggerId)
+{
+ if (triggerId == RNIL)
+ {
+ triggerId = getFreeTriggerRecord();
+ }
+ else
+ {
+ TriggerRecordPtr ptr;
+ bool ok = find_object(ptr, triggerId);
+ if (ok)
+ { // triggerId already in use
+ jam();
+ return false;
+ }
+ }
+ if (triggerId == RNIL)
+ {
+ jam();
+ return false;
+ }
+ c_triggerRecordPool.seize(triggerPtr);
+ if (triggerPtr.isNull())
+ {
+ jam();
+ return false;
+ }
+ initialiseTriggerRecord(triggerPtr, triggerId);
+ return true;
+}
+
Uint32
Dbdict::check_read_obj(Uint32 objId, Uint32 transId)
{
@@ -2933,9 +2951,9 @@ Dbdict::initSchemaFile_conf(Signal* sign
}
void
-Dbdict::activateIndexes(Signal* signal, Uint32 i)
+Dbdict::activateIndexes(Signal* signal, Uint32 id)
{
- if (i == 0)
+ if (id == 0)
D("activateIndexes start");
Uint32 requestFlags = 0;
@@ -2961,12 +2979,16 @@ Dbdict::activateIndexes(Signal* signal,
}
TableRecordPtr indexPtr;
- indexPtr.i = i;
- for (; indexPtr.i < c_noOfMetaTables; indexPtr.i++)
+ for (; id < c_noOfMetaTables; id++)
{
- c_tableRecordPool.getPtr(indexPtr);
+ bool ok = find_object(indexPtr, id);
+ if (!ok)
+ {
+ jam();
+ continue;
+ }
- if (check_read_obj(indexPtr.i))
+ if (check_read_obj(id))
{
continue;
}
@@ -2984,7 +3006,7 @@ Dbdict::activateIndexes(Signal* signal,
}
// wl3600_todo use simple schema trans when implemented
- D("activateIndexes i=" << indexPtr.i);
+ D("activateIndexes id=" << id);
TxHandlePtr tx_ptr;
seizeTxHandle(tx_ptr);
@@ -3026,8 +3048,10 @@ Dbdict::activateIndex_fromBeginTrans(Sig
ndbrequire(!tx_ptr.isNull());
TableRecordPtr indexPtr;
- indexPtr.i = tx_ptr.p->m_userData;
- c_tableRecordPool.getPtr(indexPtr);
+ c_tableRecordPool.getPtr(indexPtr, tx_ptr.p->m_userData);
+ ndbrequire(!indexPtr.isNull());
+ DictObjectPtr index_obj_ptr;
+ c_obj_pool.getPtr(index_obj_ptr, indexPtr.p->m_obj_ptr_i);
AlterIndxReq* req = (AlterIndxReq*)signal->getDataPtrSend();
@@ -3040,7 +3064,7 @@ Dbdict::activateIndex_fromBeginTrans(Sig
req->transId = tx_ptr.p->m_transId;
req->transKey = tx_ptr.p->m_transKey;
req->requestInfo = requestInfo;
- req->indexId = indexPtr.i;
+ req->indexId = index_obj_ptr.p->m_id;
req->indexVersion = indexPtr.p->tableVersion;
Callback c = {
@@ -3092,12 +3116,12 @@ Dbdict::activateIndex_fromEndTrans(Signa
TableRecordPtr indexPtr;
c_tableRecordPool.getPtr(indexPtr, tx_ptr.p->m_userData);
+ DictObjectPtr index_obj_ptr;
+ c_obj_pool.getPtr(index_obj_ptr, indexPtr.p->m_obj_ptr_i);
char indexName[MAX_TAB_NAME_SIZE];
{
- DictObjectPtr obj_ptr;
- c_obj_pool.getPtr(obj_ptr, indexPtr.p->m_obj_ptr_i);
- LocalRope name(c_rope_pool, obj_ptr.p->m_name);
+ LocalRope name(c_rope_pool, index_obj_ptr.p->m_name);
name.copy(indexName);
}
@@ -3106,38 +3130,43 @@ Dbdict::activateIndex_fromEndTrans(Signa
{
jam();
infoEvent("DICT: activate index %u done (%s)",
- indexPtr.i, indexName);
+ index_obj_ptr.p->m_id, indexName);
}
else
{
jam();
warningEvent("DICT: activate index %u error: code=%u line=%u node=%u (%s)",
- indexPtr.i,
+ index_obj_ptr.p->m_id,
error.errorCode, error.errorLine, error.errorNodeId,
indexName);
}
+ Uint32 id = index_obj_ptr.p->m_id;
releaseTxHandle(tx_ptr);
- activateIndexes(signal, indexPtr.i + 1);
+ activateIndexes(signal, id + 1);
}
void
-Dbdict::rebuildIndexes(Signal* signal, Uint32 i)
+Dbdict::rebuildIndexes(Signal* signal, Uint32 id)
{
- if (i == 0)
+ if (id == 0)
D("rebuildIndexes start");
TableRecordPtr indexPtr;
- indexPtr.i = i;
- for (; indexPtr.i < c_noOfMetaTables; indexPtr.i++) {
- c_tableRecordPool.getPtr(indexPtr);
- if (check_read_obj(indexPtr.i))
+ for (; id < c_noOfMetaTables; id++) {
+ bool ok = find_object(indexPtr, id);
+ if (!ok)
+ {
+ jam();
+ continue;
+ }
+ if (check_read_obj(id))
continue;
if (!indexPtr.p->isIndex())
continue;
// wl3600_todo use simple schema trans when implemented
- D("rebuildIndexes i=" << indexPtr.i);
+ D("rebuildIndexes id=" << id);
TxHandlePtr tx_ptr;
seizeTxHandle(tx_ptr);
@@ -3176,8 +3205,9 @@ Dbdict::rebuildIndex_fromBeginTrans(Sign
ndbrequire(!tx_ptr.isNull());
TableRecordPtr indexPtr;
- indexPtr.i = tx_ptr.p->m_userData;
- c_tableRecordPool.getPtr(indexPtr);
+ c_tableRecordPool.getPtr(indexPtr, tx_ptr.p->m_userData);
+ DictObjectPtr index_obj_ptr;
+ c_obj_pool.getPtr(index_obj_ptr,indexPtr.p->m_obj_ptr_i);
BuildIndxReq* req = (BuildIndxReq*)signal->getDataPtrSend();
@@ -3193,7 +3223,7 @@ Dbdict::rebuildIndex_fromBeginTrans(Sign
req->buildId = 0;
req->buildKey = 0;
req->tableId = indexPtr.p->primaryTableId;
- req->indexId = indexPtr.i;
+ req->indexId = index_obj_ptr.p->m_id;
req->indexType = indexPtr.p->tableType;
req->parallelism = 16;
@@ -3254,10 +3284,11 @@ Dbdict::rebuildIndex_fromEndTrans(Signal
actionName = !noBuild ? "rebuild" : "online";
}
+ DictObjectPtr obj_ptr;
+ c_obj_pool.getPtr(obj_ptr, indexPtr.p->m_obj_ptr_i);
+
char indexName[MAX_TAB_NAME_SIZE];
{
- DictObjectPtr obj_ptr;
- c_obj_pool.getPtr(obj_ptr, indexPtr.p->m_obj_ptr_i);
LocalRope name(c_rope_pool, obj_ptr.p->m_name);
name.copy(indexName);
}
@@ -3267,20 +3298,20 @@ Dbdict::rebuildIndex_fromEndTrans(Signal
jam();
infoEvent(
"DICT: %s index %u done (%s)",
- actionName, indexPtr.i, indexName);
+ actionName, obj_ptr.p->m_id, indexName);
} else {
jam();
warningEvent(
"DICT: %s index %u error: code=%u line=%u node=%u (%s)",
actionName,
- indexPtr.i, error.errorCode, error.errorLine, error.errorNodeId,
+ obj_ptr.p->m_id, error.errorCode, error.errorLine, error.errorNodeId,
indexName);
}
- Uint32 i = tx_ptr.p->m_userData;
+ Uint32 id = obj_ptr.p->m_id;
releaseTxHandle(tx_ptr);
- rebuildIndexes(signal, i + 1);
+ rebuildIndexes(signal, id + 1);
}
/* **************************************************************** */
@@ -4693,13 +4724,13 @@ Dbdict::release_object(Uint32 obj_ptr_i,
LocalRope name(c_rope_pool, obj_name);
name.erase();
+jam();
c_obj_name_hash.remove(ptr);
- if (!DictTabInfo::isTrigger(obj_ptr_p->m_type))
- {
- jam();
- c_obj_id_hash.remove(ptr);
- }
+jam();
+ c_obj_id_hash.remove(ptr);
+jam();
c_obj_pool.release(ptr);
+jam();
}
void
@@ -4774,19 +4805,16 @@ void Dbdict::handleTabInfoInit(Signal *
}
TableRecordPtr tablePtr;
+ Uint32 schemaFileId;
switch (parseP->requestType) {
case DictTabInfo::CreateTableFromAPI: {
jam();
}
case DictTabInfo::AlterTableFromAPI:{
jam();
- tablePtr.i = getFreeTableRecord();
- /* ---------------------------------------------------------------- */
- // Check if no free tables existed.
- /* ---------------------------------------------------------------- */
- tabRequire(tablePtr.i != RNIL, CreateTableRef::NoMoreTableRecords);
-
- c_tableRecordPool.getPtr(tablePtr);
+ schemaFileId = RNIL;
+ bool ok = seizeTableRecord(tablePtr,schemaFileId);
+ tabRequire(ok, CreateTableRef::NoMoreTableRecords);
break;
}
case DictTabInfo::AddTableFromDict:
@@ -4796,20 +4824,16 @@ void Dbdict::handleTabInfoInit(Signal *
/* ---------------------------------------------------------------- */
// Get table id and check that table doesn't already exist
/* ---------------------------------------------------------------- */
- tablePtr.i = c_tableDesc.TableId;
-
if (parseP->requestType == DictTabInfo::ReadTableFromDiskSR) {
- ndbrequire(tablePtr.i == c_restartRecord.activeTable);
+ ndbrequire(c_tableDesc.TableId == c_restartRecord.activeTable);
}//if
if (parseP->requestType == DictTabInfo::GetTabInfoConf) {
- ndbrequire(tablePtr.i == c_restartRecord.activeTable);
+ ndbrequire(c_tableDesc.TableId == c_restartRecord.activeTable);
}//if
- c_tableRecordPool.getPtr(tablePtr);
-
- //Uint32 oldTableVersion = tablePtr.p->tableVersion;
- initialiseTableRecord(tablePtr);
-
+ schemaFileId = c_tableDesc.TableId;
+ bool ok = seizeTableRecord(tablePtr,schemaFileId);
+ ndbrequire(ok); // Already exists or out of memory
/* ---------------------------------------------------------------- */
// Set table version
/* ---------------------------------------------------------------- */
@@ -4835,7 +4859,7 @@ void Dbdict::handleTabInfoInit(Signal *
DictObjectPtr obj_ptr;
ndbrequire(c_obj_pool.seize(obj_ptr));
new (obj_ptr.p) DictObject;
- obj_ptr.p->m_id = tablePtr.i;
+ obj_ptr.p->m_id = schemaFileId;
obj_ptr.p->m_type = c_tableDesc.TableType;
obj_ptr.p->m_name = tablePtr.p->tableName;
obj_ptr.p->m_ref_count = 0;
@@ -4847,11 +4871,11 @@ void Dbdict::handleTabInfoInit(Signal *
{
g_eventLogger->info("Dbdict: %u: create name=%s,id=%u,obj_ptr_i=%d",__LINE__,
c_tableDesc.TableName,
- tablePtr.i, tablePtr.p->m_obj_ptr_i);
+ schemaFileId, tablePtr.p->m_obj_ptr_i);
}
send_event(signal, trans_ptr,
NDB_LE_CreateSchemaObject,
- tablePtr.i,
+ schemaFileId,
tablePtr.p->tableVersion,
c_tableDesc.TableType);
}
@@ -4995,12 +5019,12 @@ void Dbdict::handleTabInfoInit(Signal *
ndbrequire(c_tableDesc.UpdateTriggerId != RNIL);
ndbrequire(c_tableDesc.DeleteTriggerId != RNIL);
ndbout_c("table: %u UPGRADE saving (%u/%u/%u)",
- tablePtr.i,
+ schemaFileId,
c_tableDesc.InsertTriggerId,
c_tableDesc.UpdateTriggerId,
c_tableDesc.DeleteTriggerId);
infoEvent("table: %u UPGRADE saving (%u/%u/%u)",
- tablePtr.i,
+ schemaFileId,
c_tableDesc.InsertTriggerId,
c_tableDesc.UpdateTriggerId,
c_tableDesc.DeleteTriggerId);
@@ -5063,62 +5087,74 @@ Dbdict::upgrade_seizeTrigger(TableRecord
ndbrequire(updateTriggerId == RNIL || updateTriggerId < size);
ndbrequire(deleteTriggerId == RNIL || deleteTriggerId < size);
+ DictObjectPtr tab_obj_ptr;
+ c_obj_pool.getPtr(tab_obj_ptr, tabPtr.p->m_obj_ptr_i);
+
TriggerRecordPtr triggerPtr;
if (updateTriggerId != RNIL)
{
jam();
- c_triggerRecordPool.getPtr(triggerPtr, updateTriggerId);
- if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED)
+ bool ok = find_object(triggerPtr, updateTriggerId);
+ if (!ok)
{
jam();
- initialiseTriggerRecord(triggerPtr);
+ bool ok = seizeTriggerRecord(triggerPtr, updateTriggerId);
+ if (!ok)
+ {
+ jam();
+ ndbrequire(ok);
+ }
triggerPtr.p->triggerState = TriggerRecord::TS_FAKE_UPGRADE;
- triggerPtr.p->triggerId = triggerPtr.i;
triggerPtr.p->tableId = tabPtr.p->primaryTableId;
- triggerPtr.p->indexId = tabPtr.i;
+ triggerPtr.p->indexId = tab_obj_ptr.p->m_id;
TriggerInfo::packTriggerInfo(triggerPtr.p->triggerInfo,
g_hashIndexTriggerTmpl[0].triggerInfo);
char buf[256];
BaseString::snprintf(buf, sizeof(buf),
- "UPG_UPD_NDB$INDEX_%u_UI", tabPtr.i);
+ "UPG_UPD_NDB$INDEX_%u_UI", tab_obj_ptr.p->m_id);
{
LocalRope name(c_rope_pool, triggerPtr.p->triggerName);
name.assign(buf);
}
DictObjectPtr obj_ptr;
- bool ok = c_obj_pool.seize(obj_ptr);
+ ok = c_obj_pool.seize(obj_ptr);
ndbrequire(ok);
new (obj_ptr.p) DictObject();
obj_ptr.p->m_name = triggerPtr.p->triggerName;
obj_ptr.p->m_ref_count = 0;
- triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
obj_ptr.p->m_id = triggerPtr.p->triggerId;
obj_ptr.p->m_type =TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
+ link_object(obj_ptr, triggerPtr);
c_obj_name_hash.add(obj_ptr);
+ c_obj_id_hash.add(obj_ptr);
}
}
if (deleteTriggerId != RNIL)
{
jam();
- c_triggerRecordPool.getPtr(triggerPtr, deleteTriggerId);
- if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED)
+ bool ok = find_object(triggerPtr, deleteTriggerId); // TODO: msundell seizeTriggerRecord
+ if (!ok)
{
jam();
- initialiseTriggerRecord(triggerPtr);
+ bool ok = seizeTriggerRecord(triggerPtr, deleteTriggerId);
+ if (!ok)
+ {
+ jam();
+ ndbrequire(ok);
+ }
triggerPtr.p->triggerState = TriggerRecord::TS_FAKE_UPGRADE;
- triggerPtr.p->triggerId = triggerPtr.i;
triggerPtr.p->tableId = tabPtr.p->primaryTableId;
- triggerPtr.p->indexId = tabPtr.i;
+ triggerPtr.p->indexId = tab_obj_ptr.p->m_id;
TriggerInfo::packTriggerInfo(triggerPtr.p->triggerInfo,
g_hashIndexTriggerTmpl[0].triggerInfo);
char buf[256];
BaseString::snprintf(buf, sizeof(buf),
- "UPG_DEL_NDB$INDEX_%u_UI", tabPtr.i);
+ "UPG_DEL_NDB$INDEX_%u_UI", tab_obj_ptr.p->m_id);
{
LocalRope name(c_rope_pool, triggerPtr.p->triggerName);
@@ -5126,17 +5162,18 @@ Dbdict::upgrade_seizeTrigger(TableRecord
}
DictObjectPtr obj_ptr;
- bool ok = c_obj_pool.seize(obj_ptr);
+ ok = c_obj_pool.seize(obj_ptr);
ndbrequire(ok);
new (obj_ptr.p) DictObject();
obj_ptr.p->m_name = triggerPtr.p->triggerName;
obj_ptr.p->m_ref_count = 0;
- triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
obj_ptr.p->m_id = triggerPtr.p->triggerId;
obj_ptr.p->m_type =TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
+ link_object(obj_ptr, triggerPtr);
c_obj_name_hash.add(obj_ptr);
+ c_obj_id_hash.add(obj_ptr);
}
}
}
@@ -5787,20 +5824,20 @@ Dbdict::createTable_parse(Signal* signal
TableRecordPtr tabPtr = parseRecord.tablePtr;
// link operation to object seized in handleTabInfoInit
+ DictObjectPtr obj_ptr;
{
- DictObjectPtr obj_ptr;
Uint32 obj_ptr_i = tabPtr.p->m_obj_ptr_i;
bool ok = findDictObject(op_ptr, obj_ptr, obj_ptr_i);
ndbrequire(ok);
}
{
- Uint32 version = getTableEntry(tabPtr.i)->m_tableVersion;
+ Uint32 version = getTableEntry(obj_ptr.p->m_id)->m_tableVersion;
tabPtr.p->tableVersion = create_obj_inc_schema_version(version);
}
// fill in table id and version
- impl_req->tableId = tabPtr.i;
+ impl_req->tableId = obj_ptr.p->m_id;
impl_req->tableVersion = tabPtr.p->tableVersion;
if (ERROR_INSERTED(6202) ||
@@ -5939,7 +5976,13 @@ Dbdict::createTable_parse(Signal* signal
}
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
tabPtr.p->packedSize = tabInfoPtr.sz;
// wl3600_todo verify version on slave
tabPtr.p->tableVersion = tableVersion;
@@ -6032,7 +6075,7 @@ Dbdict::createTable_prepare(Signal* sign
Uint32 tableId = createTabPtr.p->m_request.tableId;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
Callback cb;
cb.m_callbackData = op_ptr.p->op_key;
@@ -6048,6 +6091,7 @@ Dbdict::createTable_prepare(Signal* sign
return;
}
+ ndbrequire(ok);
bool savetodisk = !(tabPtr.p->m_bits & TableRecord::TR_Temporary);
if (savetodisk)
{
@@ -6111,7 +6155,8 @@ Dbdict::createTab_local(Signal* signal,
createTabPtr.p->m_callback = * c;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_request.tableId);
+ bool ok = find_object(tabPtr, createTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
/**
* Start by createing table in LQH
@@ -6141,7 +6186,7 @@ Dbdict::createTab_local(Signal* signal,
* Create KeyDescriptor
*/
{
- KeyDescriptor* desc= g_key_descriptor_pool.getPtr(tabPtr.i);
+ KeyDescriptor* desc= g_key_descriptor_pool.getPtr(createTabPtr.p->m_request.tableId);
new (desc) KeyDescriptor();
if (tabPtr.p->primaryTableId == RNIL)
@@ -6225,7 +6270,8 @@ Dbdict::execCREATE_TAB_CONF(Signal* sign
createTabPtr.p->m_lqhFragPtr = conf->lqhConnectPtr;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_request.tableId);
+ bool ok = find_object(tabPtr, createTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
sendLQHADDATTRREQ(signal, op_ptr, tabPtr.p->m_attributes.firstItem);
}
@@ -6240,7 +6286,8 @@ Dbdict::sendLQHADDATTRREQ(Signal* signal
getOpRec(op_ptr, createTabPtr);
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_request.tableId);
+ bool ok = find_object(tabPtr, createTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
const bool isHashIndex = tabPtr.p->isHashIndex();
@@ -6368,8 +6415,8 @@ Dbdict::createTab_dih(Signal* signal, Sc
D("createTab_dih" << *op_ptr.p);
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_request.tableId);
-
+ bool ok = find_object(tabPtr, createTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
/**
* NOTE: use array access here...
@@ -6380,7 +6427,7 @@ Dbdict::createTab_dih(Signal* signal, Sc
DiAddTabReq * req = (DiAddTabReq*)signal->getDataPtrSend();
req->connectPtr = op_ptr.p->op_key;
- req->tableId = tabPtr.i;
+ req->tableId = createTabPtr.p->m_request.tableId;
req->fragType = tabPtr.p->fragmentType;
req->kValue = tabPtr.p->kValue;
req->noOfReplicas = 0;
@@ -6480,7 +6527,8 @@ Dbdict::execADD_FRAGREQ(Signal* signal)
TableRecordPtr tabPtr;
if (AlterTableReq::getAddFragFlag(changeMask))
{
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ ndbrequire(ok);
if (DictTabInfo::isTable(tabPtr.p->tableType))
{
jam();
@@ -6507,7 +6555,8 @@ Dbdict::execADD_FRAGREQ(Signal* signal)
findSchemaOp(op_ptr, createTabPtr, senderData);
ndbrequire(!op_ptr.isNull());
createTabPtr.p->m_dihAddFragPtr = dihPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ ndbrequire(ok);
}
#if 0
@@ -6575,7 +6624,8 @@ Dbdict::execLQHFRAGCONF(Signal * signal)
jam();
SchemaOpPtr op_ptr;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ ndbrequire(ok);
if (DictTabInfo::isTable(tabPtr.p->tableType))
{
AlterTableRecPtr alterTabPtr;
@@ -6628,7 +6678,8 @@ Dbdict::execLQHFRAGREF(Signal * signal)
jam();
SchemaOpPtr op_ptr;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ ndbrequire(ok);
if (DictTabInfo::isTable(tabPtr.p->tableType))
{
jam();
@@ -6716,13 +6767,14 @@ Dbdict::execTAB_COMMITCONF(Signal* signa
//const CreateTabReq* impl_req = &createTabPtr.p->m_request;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_request.tableId);
+ bool ok = find_object(tabPtr, createTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
if (refToBlock(signal->getSendersBlockRef()) == DBLQH) {
jam();
// prepare table in DBTC
TcSchVerReq * req = (TcSchVerReq*)signal->getDataPtr();
- req->tableId = tabPtr.i;
+ req->tableId = createTabPtr.p->m_request.tableId;
req->tableVersion = tabPtr.p->tableVersion;
req->tableLogged = (Uint32)!!(tabPtr.p->m_bits & TableRecord::TR_Logged);
req->senderRef = reference();
@@ -6736,7 +6788,8 @@ Dbdict::execTAB_COMMITCONF(Signal* signa
{
jam();
TableRecordPtr basePtr;
- c_tableRecordPool.getPtr(basePtr, tabPtr.p->primaryTableId);
+ bool ok = find_object(basePtr, tabPtr.p->primaryTableId);
+ ndbrequire(ok);
req->userDefinedPartition = (basePtr.p->fragmentType == DictTabInfo::UserDefined);
}
@@ -6750,7 +6803,7 @@ Dbdict::execTAB_COMMITCONF(Signal* signa
// commit table in DBTC
signal->theData[0] = op_ptr.p->op_key;
signal->theData[1] = reference();
- signal->theData[2] = tabPtr.i;
+ signal->theData[2] = createTabPtr.p->m_request.tableId;
sendSignal(DBTC_REF, GSN_TAB_COMMITREQ, signal, 3, JBB);
return;
@@ -6815,7 +6868,8 @@ Dbdict::createTable_commit(Signal* signa
Uint32 tableId = createTabPtr.p->m_request.tableId;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
+ ndbrequire(ok);
D("createTable_commit" << *op_ptr.p);
@@ -6827,7 +6881,8 @@ Dbdict::createTable_commit(Signal* signa
if (DictTabInfo::isIndex(tabPtr.p->tableType))
{
TableRecordPtr basePtr;
- c_tableRecordPool.getPtr(basePtr, tabPtr.p->primaryTableId);
+ bool ok = find_object(basePtr, tabPtr.p->primaryTableId);
+ ndbrequire(ok);
LocalTableRecord_list list(c_tableRecordPool, basePtr.p->m_indexes);
list.add(tabPtr);
@@ -6875,7 +6930,8 @@ Dbdict::createTab_alterComplete(Signal*
const CreateTabReq* impl_req = &createTabPtr.p->m_request;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, impl_req->tableId);
+ bool ok = find_object(tabPtr, impl_req->tableId);
+ ndbrequire(ok);
D("createTab_alterComplete" << *op_ptr.p);
@@ -6937,13 +6993,17 @@ Dbdict::createTable_abortParse(Signal* s
}
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, tableId);
+ bool ok = find_object(tabPtr, tableId);
// any link was to a new object
if (hasDictObject(op_ptr)) {
jam();
unlinkDictObject(op_ptr);
- releaseTableObject(tableId, true);
+ if (ok)
+ {
+ jam();
+ releaseTableObject(tabPtr.i, true);
+ }
}
} while (0);
@@ -6962,13 +7022,14 @@ Dbdict::createTable_abortPrepare(Signal*
D("createTable_abortPrepare" << *op_ptr.p);
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, impl_req->tableId);
+ bool ok = find_object(tabPtr, impl_req->tableId);
+ ndbrequire(ok);
// create drop table operation wl3600_todo must pre-allocate
SchemaOpPtr oplnk_ptr;
DropTableRecPtr dropTabPtr;
- bool ok = seizeLinkedSchemaOp(op_ptr, oplnk_ptr, dropTabPtr);
+ ok = seizeLinkedSchemaOp(op_ptr, oplnk_ptr, dropTabPtr);
ndbrequire(ok);
DropTabReq* aux_impl_req = &dropTabPtr.p->m_request;
@@ -7024,10 +7085,12 @@ Dbdict::createTable_abortLocalConf(Signa
Uint32 tableId = impl_req->tableId;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
-
- releaseTableObject(tableId);
-
+ bool ok = find_object(tablePtr, tableId);
+ if (ok)
+ {
+ jam();
+ releaseTableObject(tablePtr.i);
+ }
createTabPtr.p->m_abortPrepareDone = true;
sendTransConf(signal, op_ptr);
}
@@ -7069,10 +7132,10 @@ void Dbdict::execCREATE_TABLE_REF(Signal
handleDictRef(signal, ref);
}
-void Dbdict::releaseTableObject(Uint32 tableId, bool removeFromHash)
+void Dbdict::releaseTableObject(Uint32 table_ptr_i, bool removeFromHash)
{
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
+ c_tableRecordPool.getPtr(tablePtr, table_ptr_i);
if (removeFromHash)
{
jam();
@@ -7124,9 +7187,12 @@ void Dbdict::releaseTableObject(Uint32 t
{
jam();
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, triggerId);
- triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
- release_object(triggerPtr.p->m_obj_ptr_i);
+ bool ok = find_object(triggerPtr, triggerId);
+ if (ok)
+ {
+ release_object(triggerPtr.p->m_obj_ptr_i);
+ c_triggerRecordPool.release(triggerPtr);
+ }
}
triggerId = tablePtr.p->m_upgrade_trigger_handling.deleteTriggerId;
@@ -7134,13 +7200,16 @@ void Dbdict::releaseTableObject(Uint32 t
{
jam();
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, triggerId);
- triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
- release_object(triggerPtr.p->m_obj_ptr_i);
+ bool ok = find_object(triggerPtr, triggerId);
+ if (ok)
+ {
+ release_object(triggerPtr.p->m_obj_ptr_i);
+ c_triggerRecordPool.release(triggerPtr);
+ }
}
}
}
-
+ c_tableRecordPool.release(tablePtr);
}//releaseTableObject()
// CreateTable: END
@@ -7252,6 +7321,7 @@ Dbdict::dropTable_parse(Signal* signal,
getOpRec(op_ptr, dropTabPtr);
DropTabReq* impl_req = &dropTabPtr.p->m_request;
Uint32 tableId = impl_req->tableId;
+ Uint32 err;
TableRecordPtr tablePtr;
if (!(tableId < c_noOfMetaTables)) {
@@ -7259,7 +7329,23 @@ Dbdict::dropTable_parse(Signal* signal,
setError(error, DropTableRef::NoSuchTable, __LINE__);
return;
}
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+
+ err = check_read_obj(impl_req->tableId, trans_ptr.p->m_transId);
+ if (err)
+ {
+ jam();
+ setError(error, err, __LINE__);
+ return;
+ }
+
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
+
// check version first (api will retry)
if (tablePtr.p->tableVersion != impl_req->tableVersion) {
@@ -7275,7 +7361,7 @@ Dbdict::dropTable_parse(Signal* signal,
return;
}
- if (check_write_obj(tablePtr.i,
+ if (check_write_obj(impl_req->tableId,
trans_ptr.p->m_transId,
SchemaFile::SF_DROP, error))
{
@@ -7301,7 +7387,7 @@ Dbdict::dropTable_parse(Signal* signal,
SchemaFile::TableEntry te; te.init();
te.m_tableState = SchemaFile::SF_DROP;
te.m_transId = trans_ptr.p->m_transId;
- Uint32 err = trans_log_schema_op(op_ptr, tableId, &te);
+ err = trans_log_schema_op(op_ptr, tableId, &te);
if (err)
{
jam();
@@ -7398,7 +7484,8 @@ Dbdict::dropTable_backup_mutex_locked(Si
const DropTabReq* impl_req = &dropTabPtr.p->m_request;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ ndbrequire(ok);
Mutex mutex(signal, c_mutexMgr, dropTabPtr.p->m_define_backup_mutex);
mutex.unlock(); // ignore response
@@ -7426,7 +7513,8 @@ Dbdict::dropTable_commit(Signal* signal,
D("dropTable_commit" << *op_ptr.p);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, dropTabPtr.p->m_request.tableId);
+ bool ok = find_object(tablePtr, dropTabPtr.p->m_request.tableId);
+ ndbrequire(ok);
if (tablePtr.p->m_tablespace_id != RNIL)
{
@@ -7441,21 +7529,21 @@ Dbdict::dropTable_commit(Signal* signal,
char buf[1024];
LocalRope name(c_rope_pool, tablePtr.p->tableName);
name.copy(buf);
- g_eventLogger->info("Dbdict: drop name=%s,id=%u,obj_id=%u", buf, tablePtr.i,
+ g_eventLogger->info("Dbdict: drop name=%s,id=%u,obj_id=%u", buf, dropTabPtr.p->m_request.tableId,
tablePtr.p->m_obj_ptr_i);
}
send_event(signal, trans_ptr,
NDB_LE_DropSchemaObject,
- tablePtr.i,
+ dropTabPtr.p->m_request.tableId,
tablePtr.p->tableVersion,
tablePtr.p->tableType);
if (DictTabInfo::isIndex(tablePtr.p->tableType))
{
TableRecordPtr basePtr;
- c_tableRecordPool.getPtr(basePtr, tablePtr.p->primaryTableId);
-
+ bool ok = find_object(basePtr, tablePtr.p->primaryTableId);
+ ndbrequire(ok);
LocalTableRecord_list list(c_tableRecordPool, basePtr.p->m_indexes);
list.remove(tablePtr);
}
@@ -7602,9 +7690,6 @@ Dbdict::dropTable_complete(Signal* signa
DropTableRecPtr dropTabPtr;
getOpRec(op_ptr, dropTabPtr);
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, dropTabPtr.p->m_request.tableId);
-
dropTabPtr.p->m_block = 0;
dropTabPtr.p->m_blockNo[0] = DBTC;
dropTabPtr.p->m_blockNo[1] = DBLQH; // wait usage + LCP
@@ -7631,9 +7716,6 @@ Dbdict::dropTable_complete_nextStep(Sign
*/
ndbrequire(!hasError(op_ptr.p->m_error));
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
-
Uint32 block = dropTabPtr.p->m_block;
Uint32 blockNo = dropTabPtr.p->m_blockNo[block];
D("dropTable_complete_nextStep" << hex << V(blockNo) << *op_ptr.p);
@@ -7716,7 +7798,12 @@ Dbdict::dropTable_complete_done(Signal*
Uint32 tableId = dropTabPtr.p->m_request.tableId;
unlinkDictObject(op_ptr);
- releaseTableObject(tableId);
+ TableRecordPtr tablePtr;
+ bool ok = find_object(tablePtr, tableId);
+ if (ok)
+ {
+ releaseTableObject(tablePtr.i);
+ }
// inform SUMA
{
@@ -7925,6 +8012,7 @@ Dbdict::alterTable_parse(Signal* signal,
AlterTableRecPtr alterTabPtr;
getOpRec(op_ptr, alterTabPtr);
AlterTabReq* impl_req = &alterTabPtr.p->m_request;
+ Uint32 err;
if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
{
@@ -7948,7 +8036,14 @@ Dbdict::alterTable_parse(Signal* signal,
setError(error, AlterTableRef::NoSuchTable, __LINE__);
return;
}
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
if (tablePtr.p->m_read_locked)
{
@@ -7957,7 +8052,7 @@ Dbdict::alterTable_parse(Signal* signal,
return;
}
- if (check_write_obj(tablePtr.i, trans_ptr.p->m_transId,
+ if (check_write_obj(impl_req->tableId, trans_ptr.p->m_transId,
SchemaFile::SF_ALTER, error))
{
jam();
@@ -8319,7 +8414,7 @@ Dbdict::alterTable_parse(Signal* signal,
te.m_gcp = 0;
te.m_transId = trans_ptr.p->m_transId;
- Uint32 err = trans_log_schema_op(op_ptr, impl_req->tableId, &te);
+ err = trans_log_schema_op(op_ptr, impl_req->tableId, &te);
if (err)
{
jam();
@@ -8438,7 +8533,8 @@ Dbdict::alterTable_subOps(Signal* signal
jam();
TableRecordPtr tabPtr;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(tabPtr, impl_req->tableId);
+ bool ok = find_object(tabPtr, impl_req->tableId);
+ ndbrequire(ok);
LocalTableRecord_list list(c_tableRecordPool, tabPtr.p->m_indexes);
Uint32 ptrI = alterTabPtr.p->m_sub_add_frag_index_ptr;
@@ -8587,6 +8683,7 @@ Dbdict::alterTable_toAlterIndex(Signal*
TableRecordPtr indexPtr;
c_tableRecordPool.getPtr(indexPtr, alterTabPtr.p->m_sub_add_frag_index_ptr);
+ ndbrequire(!indexPtr.isNull());
AlterIndxReq* req = (AlterIndxReq*)signal->getDataPtrSend();
req->clientRef = reference();
@@ -8713,8 +8810,6 @@ Dbdict::alterTable_toCreateTrigger(Signa
AlterTableRecPtr alterTablePtr;
getOpRec(op_ptr, alterTablePtr);
const AlterTabReq* impl_req = &alterTablePtr.p->m_request;
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
const TriggerTmpl& triggerTmpl = g_reorgTriggerTmpl[0];
@@ -8776,7 +8871,8 @@ Dbdict::alterTable_toCopyData(Signal* si
getOpRec(op_ptr, alterTablePtr);
const AlterTabReq* impl_req = &alterTablePtr.p->m_request;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ ndbrequire(ok);
CopyDataReq* req = (CopyDataReq*)signal->getDataPtrSend();
@@ -8951,7 +9047,8 @@ Dbdict::alterTable_backup_mutex_locked(S
const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ ndbrequire(ok);
Mutex mutex(signal, c_mutexMgr, alterTabPtr.p->m_define_backup_mutex);
mutex.unlock(); // ignore response
@@ -9152,7 +9249,8 @@ Dbdict::alterTable_commit(Signal* signal
D("alterTable_commit" << *op_ptr.p);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ ndbrequire(ok);
if (op_ptr.p->m_sections)
{
@@ -9398,7 +9496,8 @@ Dbdict::alterTable_fromCommitComplete(Si
const Uint32 tableId = impl_req->tableId;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
+ bool ok = find_object(tablePtr, tableId);
+ ndbrequire(ok);
// inform Suma so it can send events to any subscribers of the table
{
@@ -9783,7 +9882,7 @@ void Dbdict::execGET_TABLEDID_REQ(Signal
}
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_object_ptr_i);
GetTableIdConf * conf = (GetTableIdConf *)req;
conf->tableId = tablePtr.p->tableId;
@@ -10112,19 +10211,19 @@ void Dbdict::sendOLD_LIST_TABLES_CONF(Si
TableRecordPtr tablePtr;
if (DictTabInfo::isTable(type) || DictTabInfo::isIndex(type)){
- c_tableRecordPool.getPtr(tablePtr, iter.curr.p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, iter.curr.p->m_object_ptr_i);
if(reqListIndexes && (reqTableId != tablePtr.p->primaryTableId))
continue;
conf->tableData[pos] = 0;
- conf->setTableId(pos, tablePtr.i); // id
+ conf->setTableId(pos, iter.curr.p->m_id); // id
conf->setTableType(pos, type); // type
// state
if(DictTabInfo::isTable(type))
{
- SchemaFile::TableEntry * te = getTableEntry(xsf, tablePtr.i);
+ SchemaFile::TableEntry * te = getTableEntry(xsf, iter.curr.p->m_id);
switch(te->m_tableState){
case SchemaFile::SF_CREATE:
jam();
@@ -10192,24 +10291,30 @@ void Dbdict::sendOLD_LIST_TABLES_CONF(Si
}
if(DictTabInfo::isTrigger(type)){
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, iter.curr.p->m_id);
-
+ bool ok = find_object(triggerPtr, iter.curr.p->m_id);
conf->tableData[pos] = 0;
- conf->setTableId(pos, triggerPtr.i);
+ conf->setTableId(pos, iter.curr.p->m_id);
conf->setTableType(pos, type);
- switch (triggerPtr.p->triggerState) {
- case TriggerRecord::TS_DEFINING:
- conf->setTableState(pos, DictTabInfo::StateBuilding);
- break;
- case TriggerRecord::TS_OFFLINE:
- conf->setTableState(pos, DictTabInfo::StateOffline);
- break;
- case TriggerRecord::TS_ONLINE:
- conf->setTableState(pos, DictTabInfo::StateOnline);
- break;
- default:
- conf->setTableState(pos, DictTabInfo::StateBroken);
- break;
+ if (!ok)
+ {
+ conf->setTableState(pos, DictTabInfo::StateBroken);
+ }
+ else
+ {
+ switch (triggerPtr.p->triggerState) {
+ case TriggerRecord::TS_DEFINING:
+ conf->setTableState(pos, DictTabInfo::StateBuilding);
+ break;
+ case TriggerRecord::TS_OFFLINE:
+ conf->setTableState(pos, DictTabInfo::StateOffline);
+ break;
+ case TriggerRecord::TS_ONLINE:
+ conf->setTableState(pos, DictTabInfo::StateOnline);
+ break;
+ default:
+ conf->setTableState(pos, DictTabInfo::StateBroken);
+ break;
+ }
}
conf->setTableStore(pos, DictTabInfo::StoreNotLogged);
pos++;
@@ -10335,18 +10440,18 @@ void Dbdict::sendLIST_TABLES_CONF(Signal
TableRecordPtr tablePtr;
if (DictTabInfo::isTable(type) || DictTabInfo::isIndex(type)){
- c_tableRecordPool.getPtr(tablePtr, iter.curr.p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, iter.curr.p->m_object_ptr_i);
if(reqListIndexes && (reqTableId != tablePtr.p->primaryTableId))
goto flush;
ltd.requestData = 0; // clear
- ltd.setTableId(tablePtr.i); // id
+ ltd.setTableId(iter.curr.p->m_id); // id
ltd.setTableType(type); // type
// state
if(DictTabInfo::isTable(type)){
- SchemaFile::TableEntry * te = getTableEntry(xsf, tablePtr.i);
+ SchemaFile::TableEntry * te = getTableEntry(xsf, iter.curr.p->m_id);
switch(te->m_tableState){
case SchemaFile::SF_CREATE:
jam();
@@ -10413,24 +10518,31 @@ void Dbdict::sendLIST_TABLES_CONF(Signal
}
if(DictTabInfo::isTrigger(type)){
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, iter.curr.p->m_id);
+ bool ok = find_object(triggerPtr, iter.curr.p->m_id);
ltd.requestData = 0;
- ltd.setTableId(triggerPtr.i);
+ ltd.setTableId(iter.curr.p->m_id);
ltd.setTableType(type);
- switch (triggerPtr.p->triggerState) {
- case TriggerRecord::TS_DEFINING:
- ltd.setTableState(DictTabInfo::StateBuilding);
- break;
- case TriggerRecord::TS_OFFLINE:
- ltd.setTableState(DictTabInfo::StateOffline);
- break;
- case TriggerRecord::TS_ONLINE:
- ltd.setTableState(DictTabInfo::StateOnline);
- break;
- default:
- ltd.setTableState(DictTabInfo::StateBroken);
- break;
+ if (!ok)
+ {
+ ltd.setTableState(DictTabInfo::StateBroken);
+ }
+ else
+ {
+ switch (triggerPtr.p->triggerState) {
+ case TriggerRecord::TS_DEFINING:
+ ltd.setTableState(DictTabInfo::StateBuilding);
+ break;
+ case TriggerRecord::TS_OFFLINE:
+ ltd.setTableState(DictTabInfo::StateOffline);
+ break;
+ case TriggerRecord::TS_ONLINE:
+ ltd.setTableState(DictTabInfo::StateOnline);
+ break;
+ default:
+ ltd.setTableState(DictTabInfo::StateBroken);
+ break;
+ }
}
ltd.setTableStore(DictTabInfo::StoreNotLogged);
}
@@ -10760,16 +10872,16 @@ Dbdict::createIndex_parse(Signal* signal
setError(error, CreateIndxRef::InvalidPrimaryTable, __LINE__);
return;
}
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ bool ok = find_object(tablePtr, impl_req->tableId);
+ if (!ok || !tablePtr.p->isTable()) {
- if (!tablePtr.p->isTable()) {
jam();
setError(error, CreateIndxRef::InvalidPrimaryTable, __LINE__);
return;
}
Uint32 err;
- if ((err = check_read_obj(tablePtr.i, trans_ptr.p->m_transId)))
+ if ((err = check_read_obj(impl_req->tableId, trans_ptr.p->m_transId)))
{
jam();
setError(error, err, __LINE__);
@@ -10975,8 +11087,8 @@ Dbdict::createIndex_toCreateTable(Signal
getOpRec(op_ptr, createIndexPtr);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, createIndexPtr.p->m_request.tableId);
- ndbrequire(tablePtr.i == tablePtr.p->tableId);
+ bool ok = find_object(tablePtr, createIndexPtr.p->m_request.tableId);
+ ndbrequire(ok);
// signal data writer
Uint32* wbuffer = &c_indexPage.word[0];
@@ -11448,21 +11560,30 @@ Dbdict::dropIndex_parse(Signal* signal,
SectionHandle& handle, ErrorInfo& error)
{
D("dropIndex_parse" << V(op_ptr.i) << *op_ptr.p);
+ jam();
SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
DropIndexRecPtr dropIndexPtr;
getOpRec(op_ptr, dropIndexPtr);
DropIndxImplReq* impl_req = &dropIndexPtr.p->m_request;
- TableRecordPtr indexPtr;
if (!(impl_req->indexId < c_noOfMetaTables)) {
jam();
setError(error, DropIndxRef::IndexNotFound, __LINE__);
return;
}
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
- if (!indexPtr.p->isIndex())
+ Uint32 err = check_read_obj(impl_req->indexId, trans_ptr.p->m_transId);
+ if (err)
+ {
+ jam();
+ setError(error, err, __LINE__);
+ return;
+ }
+
+ TableRecordPtr indexPtr;
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ if (!ok || !indexPtr.p->isIndex())
{
jam();
setError(error, DropIndxRef::NotAnIndex, __LINE__);
@@ -11476,16 +11597,21 @@ Dbdict::dropIndex_parse(Signal* signal,
return;
}
- if (check_write_obj(indexPtr.i, trans_ptr.p->m_transId,
+ if (check_write_obj(impl_req->indexId, trans_ptr.p->m_transId,
SchemaFile::SF_DROP, error))
{
jam();
return;
}
- ndbrequire(indexPtr.p->primaryTableId != RNIL);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
+ ok = find_object(tablePtr, indexPtr.p->primaryTableId);
+ if (!ok)
+ {
+ jam();
+ setError(error, CreateIndxRef::InvalidPrimaryTable, __LINE__);
+ return;
+ }
// master sets primary table, slave verifies it agrees
if (master)
@@ -11942,7 +12068,21 @@ Dbdict::alterIndex_parse(Signal* signal,
setError(error, AlterIndxRef::IndexNotFound, __LINE__);
return;
}
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ if (check_read_obj(impl_req->indexId, trans_ptr.p->m_transId) == GetTabInfoRef::TableNotDefined)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
+ jam();
+
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
// get name for system index check later
char indexName[MAX_TAB_NAME_SIZE];
@@ -11959,7 +12099,7 @@ Dbdict::alterIndex_parse(Signal* signal,
return;
}
- if (check_write_obj(indexPtr.i, trans_ptr.p->m_transId,
+ if (check_write_obj(impl_req->indexId, trans_ptr.p->m_transId,
SchemaFile::SF_ALTER, error))
{
jam();
@@ -11995,7 +12135,8 @@ Dbdict::alterIndex_parse(Signal* signal,
ndbrequire(indexPtr.p->primaryTableId != RNIL);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
+ ok = find_object(tablePtr, indexPtr.p->primaryTableId);
+ ndbrequire(ok); // TODO:msundell set error
// master sets primary table, participant verifies it agrees
if (master)
@@ -12122,7 +12263,9 @@ void
Dbdict::set_index_stat_frag(Signal* signal, TableRecordPtr indexPtr)
{
jam();
- const Uint32 indexId = indexPtr.i;
+ DictObjectPtr index_obj_ptr;
+ c_obj_pool.getPtr(index_obj_ptr, indexPtr.p->m_obj_ptr_i);
+ const Uint32 indexId = index_obj_ptr.p->m_id;
Uint32 err = get_fragmentation(signal, indexId);
ndbrequire(err == 0);
// format: R F { fragId node1 .. nodeR } x { F }
@@ -12133,7 +12276,7 @@ Dbdict::set_index_stat_frag(Signal* sign
ndbrequire(noOfFragments != 0 && noOfReplicas != 0);
// distribute by table and index id
- const Uint32 value = indexPtr.p->primaryTableId + indexPtr.i;
+ const Uint32 value = indexPtr.p->primaryTableId + indexId;
const Uint32 fragId = value % noOfFragments;
const Uint32 fragIndex = 2 + (1 + noOfReplicas) * fragId;
const Uint32 nodeIndex = value % noOfReplicas;
@@ -12153,8 +12296,6 @@ Dbdict::alterIndex_subOps(Signal* signal
getOpRec(op_ptr, alterIndexPtr);
const AlterIndxImplReq* impl_req = &alterIndexPtr.p->m_request;
Uint32 requestType = impl_req->requestType;
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
// ops to create or drop triggers
if (alterIndexPtr.p->m_sub_trigger == false)
@@ -12206,7 +12347,10 @@ Dbdict::alterIndex_subOps(Signal* signal
return true;
}
- if (indexPtr.p->isOrderedIndex() &&
+ TableRecordPtr indexPtr;
+ bool ok = find_object(indexPtr, impl_req->indexId);
+
+ if (ok && indexPtr.p->isOrderedIndex() &&
(!alterIndexPtr.p->m_sub_index_stat_dml ||
!alterIndexPtr.p->m_sub_index_stat_mon)) {
jam();
@@ -12232,7 +12376,8 @@ Dbdict::alterIndex_toCreateTrigger(Signa
getOpRec(op_ptr, alterIndexPtr);
const AlterIndxImplReq* impl_req = &alterIndexPtr.p->m_request;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
const TriggerTmpl& triggerTmpl = alterIndexPtr.p->m_triggerTmpl[0];
@@ -12326,7 +12471,8 @@ Dbdict::alterIndex_toDropTrigger(Signal*
const AlterIndxImplReq* impl_req = &alterIndexPtr.p->m_request;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
//const TriggerTmpl& triggerTmpl = alterIndexPtr.p->m_triggerTmpl[0];
@@ -12489,7 +12635,8 @@ Dbdict::alterIndex_toIndexStat(Signal* s
DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
req->clientRef = reference();
req->clientData = op_ptr.p->op_key;
@@ -12593,7 +12740,8 @@ Dbdict::alterIndex_prepare(Signal* signa
Uint32 requestType = impl_req->requestType;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
D("alterIndex_prepare" << *op_ptr.p);
@@ -12653,7 +12801,8 @@ Dbdict::alterIndex_toCreateLocal(Signal*
const AlterIndxImplReq* impl_req = &alterIndexPtr.p->m_request;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
D("alterIndex_toCreateLocal" << *op_ptr.p);
@@ -12686,9 +12835,6 @@ Dbdict::alterIndex_toDropLocal(Signal* s
getOpRec(op_ptr, alterIndexPtr);
const AlterIndxImplReq* impl_req = &alterIndexPtr.p->m_request;
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
-
D("alterIndex_toDropLocal" << *op_ptr.p);
DropIndxImplReq* req = (DropIndxImplReq*)signal->getDataPtrSend();
@@ -12865,7 +13011,12 @@ Dbdict::alterIndex_abortParse(Signal* si
}
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, indexId);
+ bool ok = find_object(indexPtr, indexId);
+ if (!ok)
+ {
+ jam();
+ break;
+ }
switch (requestType) {
case AlterIndxImplReq::AlterIndexOnline:
@@ -13105,20 +13256,30 @@ Dbdict::buildIndex_parse(Signal* signal,
SchemaOpPtr op_ptr,
SectionHandle& handle, ErrorInfo& error)
{
- D("buildIndex_parse");
+ D("buildIndex_parse");
+ SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
BuildIndexRecPtr buildIndexPtr;
getOpRec(op_ptr, buildIndexPtr);
BuildIndxImplReq* impl_req = &buildIndexPtr.p->m_request;
+ Uint32 err;
// get index
TableRecordPtr indexPtr;
- if (!(impl_req->indexId < c_noOfMetaTables)) {
+ err = check_read_obj(impl_req->indexId, trans_ptr.p->m_transId);
+ if (err)
+ {
jam();
- setError(error, BuildIndxRef::IndexNotFound, __LINE__);
+ setError(error, err, __LINE__);
+ return;
+ }
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
return;
}
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
ndbrequire(indexPtr.p->primaryTableId == impl_req->tableId);
@@ -13129,7 +13290,13 @@ Dbdict::buildIndex_parse(Signal* signal,
setError(error, BuildIndxRef::IndexNotFound, __LINE__);
return;
}
- c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
+ ok = find_object(tablePtr, impl_req->tableId);
+ if (!ok)
+ {
+ jam();
+ setError(error, GetTabInfoRef::TableNotDefined, __LINE__);
+ return;
+ }
// set attribute lists
getIndexAttrList(indexPtr, buildIndexPtr.p->m_indexKeyList);
@@ -13401,9 +13568,6 @@ Dbdict::buildIndex_toDropConstraint(Sign
getOpRec(op_ptr, buildIndexPtr);
const BuildIndxImplReq* impl_req = &buildIndexPtr.p->m_request;
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
-
const TriggerTmpl& triggerTmpl = buildIndexPtr.p->m_triggerTmpl[0];
DropTrigReq* req = (DropTrigReq*)signal->getDataPtrSend();
@@ -13488,9 +13652,6 @@ Dbdict::buildIndex_reply(Signal* signal,
D("buildIndex_reply" << V(impl_req->indexId));
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
-
if (!hasError(error)) {
BuildIndxConf* conf = (BuildIndxConf*)signal->getDataPtrSend();
conf->senderRef = reference();
@@ -13553,7 +13714,8 @@ Dbdict:: buildIndex_toLocalBuild(Signal*
SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
D("buildIndex_toLocalBuild");
@@ -13654,7 +13816,8 @@ Dbdict::buildIndex_toLocalOnline(Signal*
const BuildIndxImplReq* impl_req = &buildIndexPtr.p->m_request;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
D("buildIndex_toLocalOnline");
@@ -13705,7 +13868,8 @@ Dbdict::buildIndex_fromLocalOnline(Signa
const BuildIndxImplReq* impl_req = &buildIndexPtr.p->m_request;
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
D("buildIndex_fromLocalOnline");
@@ -13880,20 +14044,23 @@ Dbdict::indexStat_parse(Signal* signal,
{
D("indexStat_parse");
+ SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
IndexStatRecPtr indexStatPtr;
getOpRec(op_ptr, indexStatPtr);
IndexStatImplReq* impl_req = &indexStatPtr.p->m_request;
+ Uint32 err;
// get index
TableRecordPtr indexPtr;
- if (!(impl_req->indexId < c_noOfMetaTables)) {
+ err = check_read_obj(impl_req->indexId, trans_ptr.p->m_transId);
+ if (err)
+ {
jam();
- setError(error, IndexStatRef::InvalidIndex, __LINE__);
+ setError(error, err, __LINE__);
return;
}
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
-
- if (!indexPtr.p->isOrderedIndex()) {
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ if (!ok || !indexPtr.p->isOrderedIndex()) {
jam();
setError(error, IndexStatRef::InvalidIndex, __LINE__);
return;
@@ -14023,7 +14190,8 @@ Dbdict::indexStat_toIndexStat(Signal* si
DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
req->clientRef = reference();
req->clientData = op_ptr.p->op_key;
@@ -14084,9 +14252,6 @@ Dbdict::indexStat_reply(Signal* signal,
D("indexStat_reply" << V(impl_req->indexId));
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
-
if (!hasError(error)) {
IndexStatConf* conf = (IndexStatConf*)signal->getDataPtrSend();
conf->senderRef = reference();
@@ -14143,8 +14308,8 @@ Dbdict::indexStat_toLocalStat(Signal* si
D("indexStat_toLocalStat");
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
- ndbrequire(indexPtr.p->isOrderedIndex());
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok && indexPtr.p->isOrderedIndex());
Callback c = {
safe_cast(&Dbdict::indexStat_fromLocalStat),
@@ -14352,7 +14517,12 @@ Dbdict::execINDEX_STAT_REP(Signal* signa
jam();
return;
}
- c_tableRecordPool.getPtr(indexPtr, rep->indexId);
+ bool ok = find_object(indexPtr, rep->indexId);
+ if (!ok)
+ {
+ jam();
+ return;
+ }
if (rep->indexVersion != 0 &&
rep->indexVersion != indexPtr.p->tableVersion) {
jam();
@@ -14370,7 +14540,7 @@ Dbdict::execINDEX_STAT_REP(Signal* signa
D("index stat: " << copyRope<MAX_TAB_NAME_SIZE>(indexPtr.p->tableName)
<< " request type:" << rep->requestType);
- infoEvent("DICT: index %u stats auto-update requested", indexPtr.i);
+ infoEvent("DICT: index %u stats auto-update requested", rep->indexId);
indexPtr.p->indexStatBgRequest = rep->requestType;
}
@@ -14400,8 +14570,8 @@ Dbdict::indexStatBg_process(Signal* sign
jam();
continue;
}
- c_tableRecordPool.getPtr(indexPtr, c_indexStatBgId);
- if (!indexPtr.p->isOrderedIndex()) {
+ bool ok = find_object(indexPtr, c_indexStatBgId);
+ if (!ok || !indexPtr.p->isOrderedIndex()) {
jam();
continue;
}
@@ -14437,15 +14607,16 @@ Dbdict::indexStatBg_fromBeginTrans(Signa
findTxHandle(tx_ptr, tx_key);
ndbrequire(!tx_ptr.isNull());
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, c_indexStatBgId);
-
if (ret != 0) {
jam();
indexStatBg_sendContinueB(signal);
return;
}
+ TableRecordPtr indexPtr;
+ bool ok = find_object(indexPtr, c_indexStatBgId);
+ ndbrequire(ok);
+
Callback c = {
safe_cast(&Dbdict::indexStatBg_fromIndexStat),
tx_ptr.p->tx_key
@@ -14475,13 +14646,10 @@ Dbdict::indexStatBg_fromIndexStat(Signal
findTxHandle(tx_ptr, tx_key);
ndbrequire(!tx_ptr.isNull());
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, c_indexStatBgId);
-
if (ret != 0) {
jam();
setError(tx_ptr.p->m_error, ret, __LINE__);
- warningEvent("DICT: index %u stats auto-update error: %d", indexPtr.i, ret);
+ warningEvent("DICT: index %u stats auto-update error: %d", c_indexStatBgId, ret);
}
Callback c = {
@@ -14506,17 +14674,18 @@ Dbdict::indexStatBg_fromEndTrans(Signal*
ndbrequire(!tx_ptr.isNull());
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, c_indexStatBgId);
+ bool ok = find_object(indexPtr, c_indexStatBgId);
if (ret != 0) {
jam();
// skip over but leave the request on
- warningEvent("DICT: index %u stats auto-update error: %d", indexPtr.i, ret);
+ warningEvent("DICT: index %u stats auto-update error: %d", c_indexStatBgId, ret);
} else {
jam();
+ ndbrequire(ok);
// mark request done
indexPtr.p->indexStatBgRequest = 0;
- infoEvent("DICT: index %u stats auto-update done", indexPtr.i);
+ infoEvent("DICT: index %u stats auto-update done", c_indexStatBgId);
}
releaseTxHandle(tx_ptr);
@@ -14701,7 +14870,8 @@ Dbdict::copyData_prepare(Signal* signal,
Uint32 tmp[MAX_ATTRIBUTES_IN_TABLE];
bool tabHasDiskCols = false;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, impl_req->srcTableId);
+ bool ok = find_object(tabPtr, impl_req->srcTableId);
+ ndbrequire(ok);
{
LocalAttributeRecord_list alist(c_attributeRecordPool,
tabPtr.p->m_attributes);
@@ -14802,7 +14972,8 @@ Dbdict::copyData_complete(Signal* signal
Uint32 tmp[MAX_ATTRIBUTES_IN_TABLE];
bool tabHasDiskCols = false;
TableRecordPtr tabPtr;
- c_tableRecordPool.getPtr(tabPtr, impl_req->srcTableId);
+ bool ok = find_object(tabPtr, impl_req->srcTableId);
+ ndbrequire(ok);
{
LocalAttributeRecord_list alist(c_attributeRecordPool,
tabPtr.p->m_attributes);
@@ -15073,7 +15244,7 @@ Dbdict::prepareTransactionEventSysTable
ndbrequire(opj_ptr_p != 0);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_object_ptr_i);
ndbrequire(tablePtr.i != RNIL); // system table must exist
Uint32 tableId = tablePtr.p->tableId; /* System table */
@@ -15691,7 +15862,7 @@ void Dbdict::executeTransEventSysTable(C
ndbrequire(opj_ptr_p != 0);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_object_ptr_i);
ndbrequire(tablePtr.i != RNIL); // system table must exist
Uint32 noAttr = tablePtr.p->noOfAttributes;
@@ -15871,7 +16042,7 @@ void Dbdict::parseReadEventSys(Signal* s
ndbrequire(opj_ptr_p != 0);
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_object_ptr_i);
ndbrequire(tablePtr.i != RNIL); // system table must exist
Uint32 noAttr = tablePtr.p->noOfAttributes;
@@ -15961,7 +16132,7 @@ void Dbdict::createEventUTIL_EXECUTE(Sig
}
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_id);
+ c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_object_ptr_i);
evntRec->m_request.setTableId(tablePtr.p->tableId);
evntRec->m_request.setTableVersion(tablePtr.p->tableVersion);
@@ -17735,12 +17906,17 @@ Dbdict::createTrigger_parse(Signal* sign
impl_req->triggerId = getFreeTriggerRecord();
if (impl_req->triggerId == RNIL)
{
- jam();
- setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
- return;
+ jam();
+ setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
+ return;
+ }
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ if (ok)
+ {
+ jam();
+ setError(error, CreateTrigRef::TriggerExists, __LINE__);
+ return;
}
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
- ndbrequire(triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED);
D("master allocated triggerId " << impl_req->triggerId);
}
else
@@ -17751,12 +17927,12 @@ Dbdict::createTrigger_parse(Signal* sign
setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
return;
}
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
- if (triggerPtr.p->triggerState != TriggerRecord::TS_NOT_DEFINED)
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ if (ok)
{
- jam();
- setError(error, CreateTrigRef::TriggerExists, __LINE__);
- return;
+ jam();
+ setError(error, CreateTrigRef::TriggerExists, __LINE__);
+ return;
}
D("master forced triggerId " << impl_req->triggerId);
}
@@ -17771,8 +17947,8 @@ Dbdict::createTrigger_parse(Signal* sign
setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
return;
}
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
- if (triggerPtr.p->triggerState != TriggerRecord::TS_NOT_DEFINED)
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ if (ok)
{
jam();
setError(error, CreateTrigRef::TriggerExists, __LINE__);
@@ -17781,15 +17957,20 @@ Dbdict::createTrigger_parse(Signal* sign
D("slave allocated triggerId " << hex << impl_req->triggerId);
}
- initialiseTriggerRecord(triggerPtr);
-
- triggerPtr.p->triggerId = impl_req->triggerId;
+ bool ok = seizeTriggerRecord(triggerPtr, impl_req->triggerId);
+ if (!ok)
+ {
+ jam();
+ setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
+ return;
+ }
triggerPtr.p->tableId = impl_req->tableId;
triggerPtr.p->indexId = RNIL; // feedback method connects to index
triggerPtr.p->triggerInfo = impl_req->triggerInfo;
triggerPtr.p->receiverRef = impl_req->receiverRef;
triggerPtr.p->triggerState = TriggerRecord::TS_DEFINING;
+ // TODO:msundell on failure below, leak of TriggerRecord
if (handle.m_cnt >= 2)
{
jam();
@@ -17829,12 +18010,13 @@ Dbdict::createTrigger_parse(Signal* sign
// connect to new DictObject
{
DictObjectPtr obj_ptr;
- seizeDictObject(op_ptr, obj_ptr, triggerPtr.p->triggerName);
+ seizeDictObject(op_ptr, obj_ptr, triggerPtr.p->triggerName); // added to c_obj_name_hash
obj_ptr.p->m_id = impl_req->triggerId; // wl3600_todo id
obj_ptr.p->m_type =
TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
- triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
+ link_object(obj_ptr, triggerPtr);
+ c_obj_id_hash.add(obj_ptr);
}
{
@@ -17875,7 +18057,8 @@ Dbdict::createTrigger_parse(Signal* sign
if (impl_req->indexId != RNIL)
{
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, impl_req->indexId);
+ bool ok = find_object(indexPtr, impl_req->indexId);
+ ndbrequire(ok);
triggerPtr.p->indexId = impl_req->indexId;
indexPtr.p->triggerId = impl_req->triggerId;
}
@@ -17911,7 +18094,12 @@ Dbdict::createTrigger_parse_endpoint(Sig
}
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ if (!ok)
+ {
+ jam();
+ return;
+ }
switch(TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo)){
case TriggerType::REORG_TRIGGER:
jam();
@@ -18226,8 +18414,8 @@ Dbdict::createTrigger_commit(Signal* sig
Uint32 triggerId = impl_req->triggerId;
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, triggerId);
-
+ bool ok = find_object(triggerPtr, triggerId);
+ ndbrequire(ok);
triggerPtr.p->triggerState = TriggerRecord::TS_ONLINE;
unlinkDictObject(op_ptr);
}
@@ -18291,20 +18479,24 @@ Dbdict::createTrigger_abortParse(Signal*
goto done;
}
- c_triggerRecordPool.getPtr(triggerPtr, triggerId);
-
- if (triggerPtr.p->triggerState == TriggerRecord::TS_DEFINING)
+ bool ok = find_object(triggerPtr, triggerId);
+ if (ok)
{
jam();
- triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
- }
- if (triggerPtr.p->indexId != RNIL)
- {
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, triggerPtr.p->indexId);
- triggerPtr.p->indexId = RNIL;
- indexPtr.p->triggerId = RNIL;
+ if (triggerPtr.p->indexId != RNIL)
+ {
+ TableRecordPtr indexPtr;
+ bool ok = find_object(indexPtr, triggerPtr.p->indexId);
+ if (ok)
+ {
+ jam();
+ indexPtr.p->triggerId = RNIL;
+ }
+ triggerPtr.p->indexId = RNIL;
+ }
+
+ c_triggerRecordPool.release(triggerPtr);
}
// ignore Feedback for now (referencing object will be dropped too)
@@ -18390,8 +18582,8 @@ Dbdict::send_create_trig_req(Signal* sig
const CreateTrigImplReq* impl_req = &createTriggerPtr.p->m_request;
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
-
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ ndbrequire(ok);
D("send_create_trig_req");
CreateTrigImplReq* req = (CreateTrigImplReq*)signal->getDataPtrSend();
@@ -18421,7 +18613,8 @@ Dbdict::send_create_trig_req(Signal* sig
if (triggerPtr.p->indexId != RNIL)
{
jam();
- c_tableRecordPool.getPtr(indexPtr, triggerPtr.p->indexId);
+ bool ok = find_object(indexPtr, triggerPtr.p->indexId);
+ ndbrequire(ok);
if (indexPtr.p->m_upgrade_trigger_handling.m_upgrade)
{
jam();
@@ -18641,7 +18834,13 @@ Dbdict::dropTrigger_parse(Signal* signal
setError(error, DropTrigImplRef::TriggerNotFound, __LINE__);
return;
}
- c_triggerRecordPool.getPtr(triggerPtr, impl_req->triggerId);
+ bool ok = find_object(triggerPtr, impl_req->triggerId);
+ if (!ok)
+ {
+ jam();
+ setError(error, DropTrigImplRef::TriggerNotFound, __LINE__);
+ return;
+ }
// wl3600_todo state check
}
@@ -18952,19 +19151,24 @@ Dbdict::dropTrigger_commit(Signal* signa
Uint32 triggerId = dropTriggerPtr.p->m_request.triggerId;
TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, triggerId);
-
+ bool ok = find_object(triggerPtr, triggerId);
+ ndbrequire(ok);
if (triggerPtr.p->indexId != RNIL)
{
+ jam();
TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, triggerPtr.p->indexId);
+ bool ok = find_object(indexPtr, triggerPtr.p->indexId);
+ if (ok)
+ {
+ jam();
+ indexPtr.p->triggerId = RNIL;
+ }
triggerPtr.p->indexId = RNIL;
- indexPtr.p->triggerId = RNIL;
}
// remove trigger
+ c_triggerRecordPool.release(triggerPtr);
releaseDictObject(op_ptr);
- triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
sendTransConf(signal, op_ptr);
return;
@@ -19139,7 +19343,8 @@ Dbdict::getIndexAttr(TableRecordPtr inde
TableRecordPtr tablePtr;
AttributeRecordPtr attrPtr;
- c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
+ bool ok = find_object(tablePtr, indexPtr.p->primaryTableId);
+ ndbrequire(ok);
AttributeRecord* iaRec = c_attributeRecordPool.getPtr(itAttr);
{
ConstRope tmp(c_rope_pool, iaRec->attributeName);
@@ -20403,10 +20608,14 @@ Dbdict::execBACKUP_LOCK_TAB_REQ(Signal*
Uint32 lock = req->m_lock_unlock;
TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId, true);
-
+ bool ok = find_object(tablePtr, tableId);
Uint32 err = 0;
- if(lock == BackupLockTab::LOCK_TABLE)
+ if (!ok)
+ {
+ jam();
+ err = GetTabInfoRef::InvalidTableId;
+ }
+ else if(lock == BackupLockTab::LOCK_TABLE)
{
jam();
if ((err = check_write_obj(tableId)) == 0)
@@ -29019,10 +29228,11 @@ Dbdict::check_consistency()
// triggers // should be in schema file
TriggerRecordPtr triggerPtr;
- for (triggerPtr.i = 0;
- triggerPtr.i < c_triggerRecordPool.getSize();
- triggerPtr.i++) {
- c_triggerRecordPool.getPtr(triggerPtr);
+ for (Uint32 id = 0;
+ id < c_triggerRecordPool.getSize();
+ id++) {
+ bool ok = find_object(triggerPtr, id);
+ if (!ok) continue;
switch (triggerPtr.p->triggerState) {
case TriggerRecord::TS_NOT_DEFINED:
continue;
@@ -29069,7 +29279,6 @@ void
Dbdict::check_consistency_table(TableRecordPtr tablePtr)
{
D("table " << copyRope<SZ>(tablePtr.p->tableName));
- ndbrequire(tablePtr.p->tableId == tablePtr.i);
switch (tablePtr.p->tableType) {
case DictTabInfo::SystemTable: // should just be "Table"
@@ -29111,9 +29320,8 @@ Dbdict::check_consistency_index(TableRec
}
TableRecordPtr tablePtr;
- tablePtr.i = indexPtr.p->primaryTableId;
- ndbrequire(tablePtr.i != RNIL);
- c_tableRecordPool.getPtr(tablePtr);
+ bool ok = find_object(tablePtr, indexPtr.p->primaryTableId);
+ ndbrequire(ok);
check_consistency_table(tablePtr);
bool is_unique_index = false;
@@ -29131,13 +29339,10 @@ Dbdict::check_consistency_index(TableRec
}
TriggerRecordPtr triggerPtr;
- triggerPtr.i = indexPtr.p->triggerId;
- ndbrequire(triggerPtr.i != RNIL);
- c_triggerRecordPool.getPtr(triggerPtr);
-
+ ok = find_object(triggerPtr, indexPtr.p->triggerId);
+ ndbrequire(ok);
ndbrequire(triggerPtr.p->tableId == tablePtr.p->tableId);
ndbrequire(triggerPtr.p->indexId == indexPtr.p->tableId);
- ndbrequire(triggerPtr.p->triggerId == triggerPtr.i);
check_consistency_trigger(triggerPtr);
@@ -29163,21 +29368,19 @@ Dbdict::check_consistency_trigger(Trigge
{
ndbrequire(triggerPtr.p->triggerState == TriggerRecord::TS_ONLINE);
}
- ndbrequire(triggerPtr.p->triggerId == triggerPtr.i);
TableRecordPtr tablePtr;
- tablePtr.i = triggerPtr.p->tableId;
- ndbrequire(tablePtr.i != RNIL);
- c_tableRecordPool.getPtr(tablePtr);
+ bool ok = find_object(tablePtr, triggerPtr.p->tableId);
+ ndbrequire(ok);
check_consistency_table(tablePtr);
if (triggerPtr.p->indexId != RNIL)
{
jam();
TableRecordPtr indexPtr;
- indexPtr.i = triggerPtr.p->indexId;
- c_tableRecordPool.getPtr(indexPtr);
- ndbrequire(check_read_obj(indexPtr.i) == 0);
+ ndbrequire(check_read_obj(triggerPtr.p->indexId) == 0);
+ bool ok = find_object(indexPtr, triggerPtr.p->indexId);
+ ndbrequire(ok);
ndbrequire(indexPtr.p->indexState == TableRecord::IS_ONLINE);
TriggerInfo ti;
TriggerInfo::unpackTriggerInfo(triggerPtr.p->triggerInfo, ti);
@@ -29185,7 +29388,7 @@ Dbdict::check_consistency_trigger(Trigge
case TriggerEvent::TE_CUSTOM:
if (! (triggerPtr.p->triggerState == TriggerRecord::TS_FAKE_UPGRADE))
{
- ndbrequire(triggerPtr.i == indexPtr.p->triggerId);
+ ndbrequire(triggerPtr.p->triggerId == indexPtr.p->triggerId);
}
break;
default:
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2011-11-11 13:31:19 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2011-11-18 06:47:23 +0000
@@ -459,6 +459,7 @@ public:
*/
struct TriggerRecord {
TriggerRecord() {}
+ static bool isCompatible(Uint32 type) { return DictTabInfo::isTrigger(type); }
/** Trigger state */
enum TriggerState {
@@ -506,6 +507,7 @@ public:
Uint32 c_maxNoOfTriggers;
TriggerRecord_pool c_triggerRecordPool;
+ TriggerRecord_pool& get_pool(TriggerRecordPtr) { return c_triggerRecordPool; }
RSS_AP_SNAPSHOT(c_triggerRecordPool);
/**
@@ -771,6 +773,17 @@ public:
return find_object(obj, object, id);
}
+ bool find_object(DictObjectPtr& obj, Ptr<TriggerRecord>& object, Uint32 id)
+ {
+ if (!find_trigger_object(obj, id))
+ {
+ object.setNull();
+ return false;
+ }
+ get_pool(object).getPtr(object, obj.p->m_object_ptr_i);
+ return !object.isNull();
+ }
+
bool find_object(DictObjectPtr& object, Uint32 id)
{
DictObject key;
@@ -780,6 +793,15 @@ public:
return ok;
}
+ bool find_trigger_object(DictObjectPtr& object, Uint32 id)
+ {
+ DictObject key;
+ key.m_id = id;
+ key.m_type = DictTabInfo::HashIndexTrigger; // A trigger type
+ bool ok = c_obj_id_hash.find(object, key);
+ return ok;
+ }
+
template<typename T> bool link_object(DictObjectPtr obj, Ptr<T> object)
{
if (!T::isCompatible(obj.p->m_type))
@@ -3728,14 +3750,17 @@ private:
/* ------------------------------------------------------------ */
// Drop Table Handling
/* ------------------------------------------------------------ */
- void releaseTableObject(Uint32 tableId, bool removeFromHash = true);
+ void releaseTableObject(Uint32 table_ptr_i, bool removeFromHash = true);
/* ------------------------------------------------------------ */
// General Stuff
/* ------------------------------------------------------------ */
Uint32 getFreeObjId(bool both = false);
Uint32 getFreeTableRecord();
+ bool seizeTableRecord(TableRecordPtr& tableRecord, Uint32& schemaFileId);
Uint32 getFreeTriggerRecord();
+ bool seizeTriggerRecord(TriggerRecordPtr& tableRecord, Uint32 triggerId);
+ void releaseTriggerObject(Uint32 trigger_ptr_i);
bool getNewAttributeRecord(TableRecordPtr tablePtr,
AttributeRecordPtr & attrPtr);
void packTableIntoPages(Signal* signal);
@@ -3988,10 +4013,8 @@ private:
void initWriteSchemaRecord();
void initNodeRecords();
- void initTableRecords();
- void initialiseTableRecord(TableRecordPtr tablePtr);
- void initTriggerRecords();
- void initialiseTriggerRecord(TriggerRecordPtr triggerPtr);
+ void initialiseTableRecord(TableRecordPtr tablePtr, Uint32 tableId);
+ void initialiseTriggerRecord(TriggerRecordPtr triggerPtr, Uint32 triggerId);
void initPageRecords();
Uint32 getFsConnRecord();
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2011-11-18 06:47:23 +0000
@@ -7486,7 +7486,8 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ
const Uint32 defaultFragments =
c_fragments_per_node * cnoOfNodeGroups * cnoReplicas;
const Uint32 maxFragments =
- MAX_FRAG_PER_LQH * getLqhWorkers() * cnoOfNodeGroups * cnoReplicas;
+ MAX_FRAG_PER_LQH * (getLqhWorkers() ? getLqhWorkers() : 1) *
+ cnoOfNodeGroups * cnoReplicas;
do {
NodeGroupRecordPtr NGPtr;
=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp 2011-11-16 05:47:02 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp 2011-11-18 06:47:23 +0000
@@ -36,7 +36,9 @@ void Dblqh::initData()
clcpFileSize = ZNO_CONCURRENT_LCP;
clfoFileSize = 0;
clogFileFileSize = 0;
- clogPartFileSize = 0; // Not valid until READ_CONFIG
+
+ NdbLogPartInfo lpinfo(instance());
+ clogPartFileSize = lpinfo.partCount;
cpageRefFileSize = ZPAGE_REF_FILE_SIZE;
cscanrecFileSize = 0;
=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2011-11-18 06:47:23 +0000
@@ -1220,36 +1220,31 @@ void Dblqh::execREAD_CONFIG_REQ(Signal*
m_ctx.m_config.getOwnConfigIterator();
ndbrequire(p != 0);
- clogPartFileSize = 4;
- Uint32 nodeLogParts = 4;
- ndb_mgm_get_int_parameter(p, CFG_DB_NO_REDOLOG_PARTS,
- &nodeLogParts);
- globalData.ndbLogParts = nodeLogParts;
- ndbrequire(nodeLogParts <= NDB_MAX_LOG_PARTS);
- {
- NdbLogPartInfo lpinfo(instance());
- clogPartFileSize = lpinfo.partCount; // How many are this instance responsible for...
- }
-
- if (globalData.ndbMtLqhWorkers > nodeLogParts)
+ /**
+ * TODO move check of log-parts vs. ndbMtLqhWorkers to better place
+ * (Configuration.cpp ??)
+ */
+ ndbrequire(globalData.ndbLogParts <= NDB_MAX_LOG_PARTS);
+ if (globalData.ndbMtLqhWorkers > globalData.ndbLogParts)
{
char buf[255];
BaseString::snprintf(buf, sizeof(buf),
"Trying to start %d LQH workers with only %d log parts, try initial"
" node restart to be able to use more LQH workers.",
- globalData.ndbMtLqhWorkers, nodeLogParts);
+ globalData.ndbMtLqhWorkers, globalData.ndbLogParts);
progError(__LINE__, NDBD_EXIT_INVALID_CONFIG, buf);
}
- if (nodeLogParts != 4 &&
- nodeLogParts != 8 &&
- nodeLogParts != 16)
+
+ if (globalData.ndbLogParts != 4 &&
+ globalData.ndbLogParts != 8 &&
+ globalData.ndbLogParts != 16)
{
char buf[255];
BaseString::snprintf(buf, sizeof(buf),
"Trying to start with %d log parts, number of log parts can"
" only be set to 4, 8 or 16.",
- nodeLogParts);
+ globalData.ndbLogParts);
progError(__LINE__, NDBD_EXIT_INVALID_CONFIG, buf);
}
@@ -1280,7 +1275,7 @@ void Dblqh::execREAD_CONFIG_REQ(Signal*
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TABLE, &ctabrecFileSize));
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TC_CONNECT,
&ctcConnectrecFileSize));
- clogFileFileSize = 4 * cnoLogFiles;
+ clogFileFileSize = clogPartFileSize * cnoLogFiles;
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_SCAN, &cscanrecFileSize));
cmaxAccOps = cscanrecFileSize * MAX_PARALLEL_OP_PER_SCAN;
@@ -15926,6 +15921,7 @@ void Dblqh::initLogpage(Signal* signal)
logPagePtr.p->logPageWord[ZPOS_VERSION] = NDB_VERSION;
logPagePtr.p->logPageWord[ZPOS_NO_LOG_FILES] = logPartPtr.p->noLogFiles;
logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
+ logPagePtr.p->logPageWord[ZPOS_NO_LOG_PARTS]= globalData.ndbLogParts;
ilpTcConnectptr.i = logPartPtr.p->firstLogTcrec;
if (ilpTcConnectptr.i != RNIL) {
jam();
=== modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp 2011-11-18 06:47:23 +0000
@@ -1769,6 +1769,7 @@ private:
Uint64 cabortCount;
Uint64 c_scan_count;
Uint64 c_range_scan_count;
+ Uint64 clocalReadCount;
// Resource usage counter(not monotonic)
Uint32 cconcurrentOp;
@@ -1783,6 +1784,7 @@ private:
cabortCount(0),
c_scan_count(0),
c_range_scan_count(0),
+ clocalReadCount(0),
cconcurrentOp(0) {}
Uint32 build_event_rep(Signal* signal)
@@ -1800,6 +1802,7 @@ private:
const Uint32 abortCount = diff(signal, 13, cabortCount);
const Uint32 scan_count = diff(signal, 15, c_scan_count);
const Uint32 range_scan_count = diff(signal, 17, c_range_scan_count);
+ const Uint32 localread_count = diff(signal, 19, clocalReadCount);
signal->theData[0] = NDB_LE_TransReportCounters;
signal->theData[1] = transCount;
@@ -1812,7 +1815,8 @@ private:
signal->theData[8] = abortCount;
signal->theData[9] = scan_count;
signal->theData[10] = range_scan_count;
- return 11;
+ signal->theData[11] = localread_count;
+ return 12;
}
Uint32 build_continueB(Signal* signal) const
@@ -1821,7 +1825,9 @@ private:
const Uint64* vars[] = {
&cattrinfoCount, &ctransCount, &ccommitCount,
&creadCount, &csimpleReadCount, &cwriteCount,
- &cabortCount, &c_scan_count, &c_range_scan_count };
+ &cabortCount, &c_scan_count, &c_range_scan_count,
+ &clocalReadCount
+ };
const size_t num = sizeof(vars)/sizeof(vars[0]);
for (size_t i = 0; i < num; i++)
=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-11-18 06:47:23 +0000
@@ -3356,7 +3356,10 @@ void Dbtc::tckeyreq050Lab(Signal* signal
jam();
regTcPtr->lastReplicaNo = 0;
regTcPtr->noOfNodes = 1;
- }
+
+ if (regTcPtr->tcNodedata[0] == getOwnNodeId())
+ c_counters.clocalReadCount++;
+ }
else if (Toperation == ZUNLOCK)
{
regTcPtr->m_special_op_flags &= ~TcConnectRecord::SOF_REORG_MOVING;
@@ -13260,7 +13263,8 @@ void Dbtc::execDBINFO_SCANREQ(Signal *si
{ Ndbinfo::WRITES_COUNTER, c_counters.cwriteCount },
{ Ndbinfo::ABORTS_COUNTER, c_counters.cabortCount },
{ Ndbinfo::TABLE_SCANS_COUNTER, c_counters.c_scan_count },
- { Ndbinfo::RANGE_SCANS_COUNTER, c_counters.c_range_scan_count }
+ { Ndbinfo::RANGE_SCANS_COUNTER, c_counters.c_range_scan_count },
+ { Ndbinfo::LOCAL_READ_COUNTER, c_counters.clocalReadCount }
};
const size_t num_counters = sizeof(counters) / sizeof(counters[0]);
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2011-07-05 12:46:07 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2011-11-18 06:47:23 +0000
@@ -275,6 +275,22 @@ Ndbfs::execREAD_CONFIG_REQ(Signal* signa
Uint32 noIdleFiles = 27;
ndb_mgm_get_int_parameter(p, CFG_DB_INITIAL_OPEN_FILES, &noIdleFiles);
+
+ {
+ /**
+ * each logpart keeps up to 3 logfiles open at any given time...
+ * (bound)
+ * make sure noIdleFiles is atleast 4 times #logparts
+ */
+ Uint32 logParts = NDB_DEFAULT_LOG_PARTS;
+ ndb_mgm_get_int_parameter(p, CFG_DB_NO_REDOLOG_PARTS, &logParts);
+ Uint32 logfiles = 4 * logParts;
+ if (noIdleFiles < logfiles)
+ {
+ noIdleFiles = logfiles;
+ }
+ }
+
// Make sure at least "noIdleFiles" files can be created
if (noIdleFiles > m_maxFiles && m_maxFiles != 0)
m_maxFiles = noIdleFiles;
=== added file 'storage/ndb/src/kernel/blocks/trpman.cpp'
--- a/storage/ndb/src/kernel/blocks/trpman.cpp 1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/kernel/blocks/trpman.cpp 2011-11-16 15:38:25 +0000
@@ -0,0 +1,648 @@
+/*
+ Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ 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; version 2 of the License.
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "trpman.hpp"
+#include <TransporterRegistry.hpp>
+#include <signaldata/CloseComReqConf.hpp>
+#include <signaldata/DisconnectRep.hpp>
+#include <signaldata/EnableCom.hpp>
+#include <signaldata/RouteOrd.hpp>
+#include <signaldata/DumpStateOrd.hpp>
+
+Trpman::Trpman(Block_context & ctx, Uint32 instanceno) :
+ SimulatedBlock(TRPMAN, ctx, instanceno)
+{
+ BLOCK_CONSTRUCTOR(Trpman);
+
+ addRecSignal(GSN_CLOSE_COMREQ, &Trpman::execCLOSE_COMREQ);
+ addRecSignal(GSN_OPEN_COMREQ, &Trpman::execOPEN_COMREQ);
+ addRecSignal(GSN_ENABLE_COMREQ, &Trpman::execENABLE_COMREQ);
+ addRecSignal(GSN_DISCONNECT_REP, &Trpman::execDISCONNECT_REP);
+ addRecSignal(GSN_CONNECT_REP, &Trpman::execCONNECT_REP);
+ addRecSignal(GSN_ROUTE_ORD, &Trpman::execROUTE_ORD);
+
+ addRecSignal(GSN_NDB_TAMPER, &Trpman::execNDB_TAMPER, true);
+ addRecSignal(GSN_DUMP_STATE_ORD, &Trpman::execDUMP_STATE_ORD);
+ addRecSignal(GSN_DBINFO_SCANREQ, &Trpman::execDBINFO_SCANREQ);
+}
+
+Trpman::~Trpman()
+{
+}
+
+BLOCK_FUNCTIONS(Trpman)
+
+#ifdef ERROR_INSERT
+NodeBitmask c_error_9000_nodes_mask;
+extern Uint32 MAX_RECEIVED_SIGNALS;
+#endif
+
+void
+Trpman::execOPEN_COMREQ(Signal* signal)
+{
+ // Connect to the specifed NDB node, only QMGR allowed communication
+ // so far with the node
+
+ const BlockReference userRef = signal->theData[0];
+ Uint32 tStartingNode = signal->theData[1];
+ Uint32 tData2 = signal->theData[2];
+ jamEntry();
+
+ const Uint32 len = signal->getLength();
+ if (len == 2)
+ {
+#ifdef ERROR_INSERT
+ if (! ((ERROR_INSERTED(9000) || ERROR_INSERTED(9002))
+ && c_error_9000_nodes_mask.get(tStartingNode)))
+#endif
+ {
+ globalTransporterRegistry.do_connect(tStartingNode);
+ globalTransporterRegistry.setIOState(tStartingNode, HaltIO);
+
+ //-----------------------------------------------------
+ // Report that the connection to the node is opened
+ //-----------------------------------------------------
+ signal->theData[0] = NDB_LE_CommunicationOpened;
+ signal->theData[1] = tStartingNode;
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
+ //-----------------------------------------------------
+ }
+ }
+ else
+ {
+ for(unsigned int i = 1; i < MAX_NODES; i++ )
+ {
+ jam();
+ if (i != getOwnNodeId() && getNodeInfo(i).m_type == tData2)
+ {
+ jam();
+
+#ifdef ERROR_INSERT
+ if ((ERROR_INSERTED(9000) || ERROR_INSERTED(9002))
+ && c_error_9000_nodes_mask.get(i))
+ continue;
+#endif
+ globalTransporterRegistry.do_connect(i);
+ globalTransporterRegistry.setIOState(i, HaltIO);
+
+ signal->theData[0] = NDB_LE_CommunicationOpened;
+ signal->theData[1] = i;
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
+ }
+ }
+ }
+
+ if (userRef != 0)
+ {
+ jam();
+ signal->theData[0] = tStartingNode;
+ signal->theData[1] = tData2;
+ sendSignal(userRef, GSN_OPEN_COMCONF, signal, len - 1,JBA);
+ }
+}
+
+void
+Trpman::execCONNECT_REP(Signal *signal)
+{
+ const Uint32 hostId = signal->theData[0];
+ jamEntry();
+
+ const NodeInfo::NodeType type = (NodeInfo::NodeType)getNodeInfo(hostId).m_type;
+ ndbrequire(type != NodeInfo::INVALID);
+ globalData.m_nodeInfo[hostId].m_version = 0;
+ globalData.m_nodeInfo[hostId].m_mysql_version = 0;
+
+ /**
+ * Inform QMGR that client has connected
+ */
+ signal->theData[0] = hostId;
+ if (ERROR_INSERTED(9005))
+ {
+ sendSignalWithDelay(QMGR_REF, GSN_CONNECT_REP, signal, 50, 1);
+ }
+ else
+ {
+ sendSignal(QMGR_REF, GSN_CONNECT_REP, signal, 1, JBA);
+ }
+
+ /* Automatically subscribe events for MGM nodes.
+ */
+ if (type == NodeInfo::MGM)
+ {
+ jam();
+ globalTransporterRegistry.setIOState(hostId, NoHalt);
+ }
+
+ //------------------------------------------
+ // Also report this event to the Event handler
+ //------------------------------------------
+ signal->theData[0] = NDB_LE_Connected;
+ signal->theData[1] = hostId;
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
+}
+
+void
+Trpman::execCLOSE_COMREQ(Signal* signal)
+{
+ // Close communication with the node and halt input/output from
+ // other blocks than QMGR
+
+ CloseComReqConf * const closeCom = (CloseComReqConf *)&signal->theData[0];
+
+ const BlockReference userRef = closeCom->xxxBlockRef;
+ Uint32 requestType = closeCom->requestType;
+ Uint32 failNo = closeCom->failNo;
+// Uint32 noOfNodes = closeCom->noOfNodes;
+
+ jamEntry();
+ for (unsigned i = 0; i < MAX_NODES; i++)
+ {
+ if (NodeBitmask::get(closeCom->theNodes, i))
+ {
+ jam();
+
+ //-----------------------------------------------------
+ // Report that the connection to the node is closed
+ //-----------------------------------------------------
+ signal->theData[0] = NDB_LE_CommunicationClosed;
+ signal->theData[1] = i;
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
+
+ globalTransporterRegistry.setIOState(i, HaltIO);
+ globalTransporterRegistry.do_disconnect(i);
+ }
+ }
+
+ if (requestType != CloseComReqConf::RT_NO_REPLY)
+ {
+ ndbassert((requestType == CloseComReqConf::RT_API_FAILURE) ||
+ ((requestType == CloseComReqConf::RT_NODE_FAILURE) &&
+ (failNo != 0)));
+ jam();
+ CloseComReqConf* closeComConf = (CloseComReqConf *)signal->getDataPtrSend();
+ closeComConf->xxxBlockRef = userRef;
+ closeComConf->requestType = requestType;
+ closeComConf->failNo = failNo;
+
+ /* Note assumption that noOfNodes and theNodes
+ * bitmap is not trampled above
+ * signals received from the remote node.
+ */
+ sendSignal(QMGR_REF, GSN_CLOSE_COMCONF, signal, 19, JBA);
+ }
+}
+
+void
+Trpman::execENABLE_COMREQ(Signal* signal)
+{
+ jamEntry();
+ const EnableComReq *enableComReq = (const EnableComReq *)signal->getDataPtr();
+
+ /* Need to copy out signal data to not clobber it with sendSignal(). */
+ Uint32 senderRef = enableComReq->m_senderRef;
+ Uint32 senderData = enableComReq->m_senderData;
+ Uint32 nodes[NodeBitmask::Size];
+ MEMCOPY_NO_WORDS(nodes, enableComReq->m_nodeIds, NodeBitmask::Size);
+
+ /* Enable communication with all our NDB blocks to these nodes. */
+ Uint32 search_from = 0;
+ for (;;)
+ {
+ Uint32 tStartingNode = NodeBitmask::find(nodes, search_from);
+ if (tStartingNode == NodeBitmask::NotFound)
+ break;
+ search_from = tStartingNode + 1;
+
+ globalTransporterRegistry.setIOState(tStartingNode, NoHalt);
+ setNodeInfo(tStartingNode).m_connected = true;
+
+ //-----------------------------------------------------
+ // Report that the version of the node
+ //-----------------------------------------------------
+ signal->theData[0] = NDB_LE_ConnectedApiVersion;
+ signal->theData[1] = tStartingNode;
+ signal->theData[2] = getNodeInfo(tStartingNode).m_version;
+ signal->theData[3] = getNodeInfo(tStartingNode).m_mysql_version;
+
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 4, JBB);
+ //-----------------------------------------------------
+ }
+
+ EnableComConf *enableComConf = (EnableComConf *)signal->getDataPtrSend();
+ enableComConf->m_senderRef = reference();
+ enableComConf->m_senderData = senderData;
+ MEMCOPY_NO_WORDS(enableComConf->m_nodeIds, nodes, NodeBitmask::Size);
+ sendSignal(senderRef, GSN_ENABLE_COMCONF, signal,
+ EnableComConf::SignalLength, JBA);
+}
+
+void
+Trpman::execDISCONNECT_REP(Signal *signal)
+{
+ const DisconnectRep * const rep = (DisconnectRep *)&signal->theData[0];
+ const Uint32 hostId = rep->nodeId;
+ jamEntry();
+
+ setNodeInfo(hostId).m_connected = false;
+ setNodeInfo(hostId).m_connectCount++;
+ const NodeInfo::NodeType type = getNodeInfo(hostId).getType();
+ ndbrequire(type != NodeInfo::INVALID);
+
+ sendSignal(QMGR_REF, GSN_DISCONNECT_REP, signal,
+ DisconnectRep::SignalLength, JBA);
+
+ signal->theData[0] = hostId;
+ sendSignal(CMVMI_REF, GSN_CANCEL_SUBSCRIPTION_REQ, signal, 1, JBB);
+
+ signal->theData[0] = NDB_LE_Disconnected;
+ signal->theData[1] = hostId;
+ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
+}
+
+/**
+ * execROUTE_ORD
+ * Allows other blocks to route signals as if they
+ * came from TRPMAN
+ * Useful in ndbmtd for synchronising signals w.r.t
+ * external signals received from other nodes which
+ * arrive from the same thread that runs TRPMAN
+ */
+void
+Trpman::execROUTE_ORD(Signal* signal)
+{
+ jamEntry();
+ if (!assembleFragments(signal))
+ {
+ jam();
+ return;
+ }
+
+ SectionHandle handle(this, signal);
+
+ RouteOrd* ord = (RouteOrd*)signal->getDataPtr();
+ Uint32 dstRef = ord->dstRef;
+ Uint32 srcRef = ord->srcRef;
+ Uint32 gsn = ord->gsn;
+ /* ord->cnt ignored */
+
+ Uint32 nodeId = refToNode(dstRef);
+
+ if (likely((nodeId == 0) ||
+ getNodeInfo(nodeId).m_connected))
+ {
+ jam();
+ Uint32 secCount = handle.m_cnt;
+ ndbrequire(secCount >= 1 && secCount <= 3);
+
+ jamLine(secCount);
+
+ /**
+ * Put section 0 in signal->theData
+ */
+ Uint32 sigLen = handle.m_ptr[0].sz;
+ ndbrequire(sigLen <= 25);
+ copy(signal->theData, handle.m_ptr[0]);
+
+ SegmentedSectionPtr save = handle.m_ptr[0];
+ for (Uint32 i = 0; i < secCount - 1; i++)
+ handle.m_ptr[i] = handle.m_ptr[i+1];
+ handle.m_cnt--;
+
+ sendSignal(dstRef, gsn, signal, sigLen, JBB, &handle);
+
+ handle.m_cnt = 1;
+ handle.m_ptr[0] = save;
+ releaseSections(handle);
+ return ;
+ }
+
+ releaseSections(handle);
+ warningEvent("Unable to route GSN: %d from %x to %x",
+ gsn, srcRef, dstRef);
+}
+
+void
+Trpman::execDBINFO_SCANREQ(Signal *signal)
+{
+ DbinfoScanReq req= *(DbinfoScanReq*)signal->theData;
+ const Ndbinfo::ScanCursor* cursor =
+ CAST_CONSTPTR(Ndbinfo::ScanCursor, DbinfoScan::getCursorPtr(&req));
+ Ndbinfo::Ratelimit rl;
+
+ jamEntry();
+
+ switch(req.tableId){
+ case Ndbinfo::TRANSPORTERS_TABLEID:
+ {
+ jam();
+ Uint32 rnode = cursor->data[0];
+ if (rnode == 0)
+ rnode++; // Skip node 0
+
+ while (rnode < MAX_NODES)
+ {
+ switch(getNodeInfo(rnode).m_type)
+ {
+ default:
+ {
+ jam();
+ Ndbinfo::Row row(signal, req);
+ row.write_uint32(getOwnNodeId()); // Node id
+ row.write_uint32(rnode); // Remote node id
+ row.write_uint32(globalTransporterRegistry.getPerformState(rnode)); // State
+ ndbinfo_send_row(signal, req, row, rl);
+ break;
+ }
+
+ case NodeInfo::INVALID:
+ jam();
+ break;
+ }
+
+ rnode++;
+ if (rl.need_break(req))
+ {
+ jam();
+ ndbinfo_send_scan_break(signal, req, rl, rnode);
+ return;
+ }
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ ndbinfo_send_scan_conf(signal, req, rl);
+}
+
+void
+Trpman::execNDB_TAMPER(Signal* signal)
+{
+ jamEntry();
+#ifdef ERROR_INSERT
+ if (signal->theData[0] == 9003)
+ {
+ if (MAX_RECEIVED_SIGNALS < 1024)
+ {
+ MAX_RECEIVED_SIGNALS = 1024;
+ }
+ else
+ {
+ MAX_RECEIVED_SIGNALS = 1 + (rand() % 128);
+ }
+ ndbout_c("MAX_RECEIVED_SIGNALS: %d", MAX_RECEIVED_SIGNALS);
+ CLEAR_ERROR_INSERT_VALUE;
+ }
+#endif
+}//execNDB_TAMPER()
+
+void
+Trpman::execDUMP_STATE_ORD(Signal* signal)
+{
+ DumpStateOrd * const & dumpState = (DumpStateOrd *)&signal->theData[0];
+ Uint32 arg = dumpState->args[0]; (void)arg;
+
+#ifdef ERROR_INSERT
+ if (arg == 9000 || arg == 9002)
+ {
+ SET_ERROR_INSERT_VALUE(arg);
+ for (Uint32 i = 1; i<signal->getLength(); i++)
+ c_error_9000_nodes_mask.set(signal->theData[i]);
+ }
+
+ if (arg == 9001)
+ {
+ CLEAR_ERROR_INSERT_VALUE;
+ if (signal->getLength() == 1 || signal->theData[1])
+ {
+ for (Uint32 i = 0; i<MAX_NODES; i++)
+ {
+ if (c_error_9000_nodes_mask.get(i))
+ {
+ signal->theData[0] = 0;
+ signal->theData[1] = i;
+ execOPEN_COMREQ(signal);
+ }
+ }
+ }
+ c_error_9000_nodes_mask.clear();
+ }
+
+ if (arg == 9004 && signal->getLength() == 2)
+ {
+ SET_ERROR_INSERT_VALUE(9004);
+ c_error_9000_nodes_mask.clear();
+ c_error_9000_nodes_mask.set(signal->theData[1]);
+ }
+
+ if (arg == 9005 && signal->getLength() == 2 && ERROR_INSERTED(9004))
+ {
+ Uint32 db = signal->theData[1];
+ Uint32 i = c_error_9000_nodes_mask.find(0);
+ signal->theData[0] = i;
+ sendSignal(calcQmgrBlockRef(db),GSN_API_FAILREQ, signal, 1, JBA);
+ ndbout_c("stopping %u using %u", i, db);
+ CLEAR_ERROR_INSERT_VALUE;
+ }
+#endif
+
+#ifdef ERROR_INSERT
+ /* <Target NodeId> dump 9992 <NodeId list>
+ * On Target NodeId, block receiving signals from NodeId list
+ *
+ * <Target NodeId> dump 9993 <NodeId list>
+ * On Target NodeId, resume receiving signals from NodeId list
+ *
+ * <Target NodeId> dump 9991
+ * On Target NodeId, resume receiving signals from any blocked node
+ *
+ *
+ * See also code in QMGR for blocking receive from nodes based
+ * on HB roles.
+ *
+ */
+ if((arg == 9993) || /* Unblock recv from nodeid */
+ (arg == 9992)) /* Block recv from nodeid */
+ {
+ bool block = (arg == 9992);
+ for (Uint32 n = 1; n < signal->getLength(); n++)
+ {
+ Uint32 nodeId = signal->theData[n];
+
+ if ((nodeId > 0) &&
+ (nodeId < MAX_NODES))
+ {
+ if (block)
+ {
+ ndbout_c("CMVMI : Blocking receive from node %u", nodeId);
+
+ globalTransporterRegistry.blockReceive(nodeId);
+ }
+ else
+ {
+ ndbout_c("CMVMI : Unblocking receive from node %u", nodeId);
+
+ globalTransporterRegistry.unblockReceive(nodeId);
+ }
+ }
+ else
+ {
+ ndbout_c("CMVMI : Ignoring dump %u for node %u",
+ arg, nodeId);
+ }
+ }
+ }
+ if (arg == 9990) /* Block recv from all ndbd matching pattern */
+ {
+ Uint32 pattern = 0;
+ if (signal->getLength() > 1)
+ {
+ pattern = signal->theData[1];
+ ndbout_c("CMVMI : Blocking receive from all ndbds matching pattern -%s-",
+ ((pattern == 1)? "Other side":"Unknown"));
+ }
+
+ for (Uint32 node = 1; node < MAX_NDB_NODES; node++)
+ {
+ if (globalTransporterRegistry.is_connected(node))
+ {
+ if (getNodeInfo(node).m_type == NodeInfo::DB)
+ {
+ if (!globalTransporterRegistry.isBlocked(node))
+ {
+ switch (pattern)
+ {
+ case 1:
+ {
+ /* Match if given node is on 'other side' of
+ * 2-replica cluster
+ */
+ if ((getOwnNodeId() & 1) != (node & 1))
+ {
+ /* Node is on the 'other side', match */
+ break;
+ }
+ /* Node is on 'my side', don't match */
+ continue;
+ }
+ default:
+ break;
+ }
+ ndbout_c("CMVMI : Blocking receive from node %u", node);
+ globalTransporterRegistry.blockReceive(node);
+ }
+ }
+ }
+ }
+ }
+ if (arg == 9991) /* Unblock recv from all blocked */
+ {
+ for (Uint32 node = 0; node < MAX_NODES; node++)
+ {
+ if (globalTransporterRegistry.isBlocked(node))
+ {
+ ndbout_c("CMVMI : Unblocking receive from node %u", node);
+ globalTransporterRegistry.unblockReceive(node);
+ }
+ }
+ }
+#endif
+}
+
+TrpmanProxy::TrpmanProxy(Block_context & ctx) :
+ LocalProxy(TRPMAN, ctx)
+{
+ addRecSignal(GSN_CLOSE_COMREQ, &TrpmanProxy::execCLOSE_COMREQ);
+ addRecSignal(GSN_OPEN_COMREQ, &TrpmanProxy::execOPEN_COMREQ);
+ addRecSignal(GSN_ENABLE_COMREQ, &TrpmanProxy::execENABLE_COMREQ);
+ addRecSignal(GSN_DISCONNECT_REP, &TrpmanProxy::execDISCONNECT_REP);
+ addRecSignal(GSN_CONNECT_REP, &TrpmanProxy::execCONNECT_REP);
+ addRecSignal(GSN_ROUTE_ORD, &TrpmanProxy::execROUTE_ORD);
+}
+
+TrpmanProxy::~TrpmanProxy()
+{
+}
+
+SimulatedBlock*
+TrpmanProxy::newWorker(Uint32 instanceNo)
+{
+ return new Trpman(m_ctx, instanceNo);
+}
+
+BLOCK_FUNCTIONS(TrpmanProxy);
+
+/**
+ * TODO TrpmanProxy need to have operation records
+ * to support splicing a request onto several Trpman-instances
+ * according to how receive-threads are assigned to instances
+ */
+void
+TrpmanProxy::execOPEN_COMREQ(Signal* signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_OPEN_COMREQ, signal,
+ signal->getLength(), JBB, &handle);
+}
+
+void
+TrpmanProxy::execCONNECT_REP(Signal *signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_CONNECT_REP, signal,
+ signal->getLength(), JBB, &handle);
+}
+
+void
+TrpmanProxy::execCLOSE_COMREQ(Signal* signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_CLOSE_COMREQ, signal,
+ signal->getLength(), JBB, &handle);
+}
+
+void
+TrpmanProxy::execENABLE_COMREQ(Signal* signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_ENABLE_COMREQ, signal,
+ signal->getLength(), JBB, &handle);
+}
+
+void
+TrpmanProxy::execDISCONNECT_REP(Signal *signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_DISCONNECT_REP, signal,
+ signal->getLength(), JBB, &handle);
+}
+
+void
+TrpmanProxy::execROUTE_ORD(Signal* signal)
+{
+ jamEntry();
+ SectionHandle handle(this, signal);
+ sendSignal(workerRef(0), GSN_ROUTE_ORD, signal,
+ signal->getLength(), JBB, &handle);
+}
=== added file 'storage/ndb/src/kernel/blocks/trpman.hpp'
--- a/storage/ndb/src/kernel/blocks/trpman.hpp 1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/kernel/blocks/trpman.hpp 2011-11-16 15:38:25 +0000
@@ -0,0 +1,66 @@
+/*
+ Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ 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; version 2 of the License.
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef TRPMAN_H
+#define TRPMAN_H
+
+#include <pc.hpp>
+#include <SimulatedBlock.hpp>
+#include <LocalProxy.hpp>
+
+class Trpman : public SimulatedBlock
+{
+public:
+ Trpman(Block_context& ctx, Uint32 instanceNumber = 0);
+ virtual ~Trpman();
+ BLOCK_DEFINES(Trpman);
+
+ void execCLOSE_COMREQ(Signal *signal);
+ void execOPEN_COMREQ(Signal *signal);
+ void execENABLE_COMREQ(Signal *signal);
+ void execDISCONNECT_REP(Signal *signal);
+ void execCONNECT_REP(Signal *signal);
+ void execROUTE_ORD(Signal* signal);
+
+ void execDBINFO_SCANREQ(Signal*);
+
+ void execNDB_TAMPER(Signal*);
+ void execDUMP_STATE_ORD(Signal*);
+protected:
+
+};
+
+class TrpmanProxy : public LocalProxy
+{
+public:
+ TrpmanProxy(Block_context& ctx);
+ virtual ~TrpmanProxy();
+ BLOCK_DEFINES(TrpmanProxy);
+
+ void execCLOSE_COMREQ(Signal *signal);
+ void execOPEN_COMREQ(Signal *signal);
+ void execENABLE_COMREQ(Signal *signal);
+ void execDISCONNECT_REP(Signal *signal);
+ void execCONNECT_REP(Signal *signal);
+ void execROUTE_ORD(Signal* signal);
+
+ void execNDB_TAMPER(Signal*);
+ void execDUMP_STATE_ORD(Signal*);
+protected:
+ virtual SimulatedBlock* newWorker(Uint32 instanceNo);
+};
+#endif
=== modified file 'storage/ndb/src/kernel/ndbd.cpp'
--- a/storage/ndb/src/kernel/ndbd.cpp 2011-10-07 13:15:08 +0000
+++ b/storage/ndb/src/kernel/ndbd.cpp 2011-11-16 11:05:46 +0000
@@ -161,9 +161,13 @@ init_global_memory_manager(EmulatorData
ed.m_mem_manager->set_resource_limit(rl);
}
- Uint32 maxopen = 4 * 4; // 4 redo parts, max 4 files per part
+ Uint32 logParts = NDB_DEFAULT_LOG_PARTS;
+ ndb_mgm_get_int_parameter(p, CFG_DB_NO_REDOLOG_PARTS, &logParts);
+
+ Uint32 maxopen = logParts * 4; // 4 redo parts, max 4 files per part
Uint32 filebuffer = NDB_FILE_BUFFER_SIZE;
Uint32 filepages = (filebuffer / GLOBAL_PAGE_SIZE) * maxopen;
+ globalData.ndbLogParts = logParts;
{
/**
=== modified file 'storage/ndb/src/kernel/vm/Ndbinfo.hpp'
--- a/storage/ndb/src/kernel/vm/Ndbinfo.hpp 2011-10-20 19:52:11 +0000
+++ b/storage/ndb/src/kernel/vm/Ndbinfo.hpp 2011-11-18 06:47:23 +0000
@@ -194,7 +194,8 @@ public:
SPJ_SCAN_BATCHES_RETURNED_COUNTER = 20,
SPJ_SCAN_ROWS_RETURNED_COUNTER = 21,
SPJ_PRUNED_RANGE_SCANS_RECEIVED_COUNTER = 22,
- SPJ_CONST_PRUNED_RANGE_SCANS_RECEIVED_COUNTER = 23
+ SPJ_CONST_PRUNED_RANGE_SCANS_RECEIVED_COUNTER = 23,
+ LOCAL_READ_COUNTER = 24
};
struct counter_entry {
=== modified file 'storage/ndb/tools/ndbinfo_sql.cpp'
--- a/storage/ndb/tools/ndbinfo_sql.cpp 2011-11-16 08:17:17 +0000
+++ b/storage/ndb/tools/ndbinfo_sql.cpp 2011-11-18 06:47:23 +0000
@@ -134,6 +134,7 @@ struct view {
" WHEN 21 THEN \"SCAN_ROWS_RETURNED\""
" WHEN 22 THEN \"PRUNED_RANGE_SCANS_RECEIVED\""
" WHEN 23 THEN \"CONST_PRUNED_RANGE_SCANS_RECEIVED\""
+ " WHEN 24 THEN \"LOCAL_READS\""
" ELSE \"<unknown>\" "
" END AS counter_name, "
"val "
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (jonas.oreland:3652 to 3653) | jonas oreland | 18 Nov |