4413 Jonas Oreland 2011-05-25
ndb - change implementation of DIVERIFY_queue to be a srsw array based queue (easy to make thread safe) instead of linked-list
modified:
storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
4412 Jonas Oreland 2011-05-25
ndb - mttc - increase obfuscation by passing an EmulatedJamBuffer* in signal->theData for DIGETNODESREQ and DIVERIFYREQ. This to allow these two signals to be called from different threads (execute direct)
modified:
storage/ndb/include/kernel/signaldata/DiGetNodes.hpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
4411 jonas oreland 2011-05-24 [merge]
ndb - merge 63 to 70
modified:
storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp
storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
=== modified file 'storage/ndb/include/kernel/signaldata/DiGetNodes.hpp'
--- a/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp 2011-02-08 13:55:54 +0000
+++ b/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp 2011-05-25 06:58:00 +0000
@@ -58,10 +58,13 @@ class DiGetNodesReq {
*/
friend class Dbdih;
public:
- STATIC_CONST( SignalLength = 3 );
+ STATIC_CONST( SignalLength = 4 + (sizeof(void*) / sizeof(Uint32)) );
private:
Uint32 tableId;
Uint32 hashValue;
Uint32 distr_key_indicator;
+ Uint32 unused;
+ Uint32 jamBuffer[2];
};
+
#endif
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp 2011-05-18 09:07:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp 2011-05-25 07:58:32 +0000
@@ -122,7 +122,7 @@ public:
* ONGOING */
struct ApiConnectRecord {
Uint64 apiGci;
- Uint32 nextApi;
+ Uint32 senderData;
};
typedef Ptr<ApiConnectRecord> ApiConnectRecordPtr;
@@ -1315,19 +1315,17 @@ private:
struct DIVERIFY_queue
{
DIVERIFY_queue() {
- cfirstVerifyQueue = clastVerifyQueue = RNIL;
- cverifyQueueCounter = 0;
+ cfirstVerifyQueue = clastVerifyQueue = 0;
apiConnectRecord = 0;
}
+ ApiConnectRecord *apiConnectRecord;
Uint32 cfirstVerifyQueue;
Uint32 clastVerifyQueue;
- Uint32 cverifyQueueCounter;
- ApiConnectRecord *apiConnectRecord;
};
bool isEmpty(const DIVERIFY_queue&);
- void enqueue(DIVERIFY_queue&, Ptr<ApiConnectRecord>);
- void dequeue(DIVERIFY_queue&, Ptr<ApiConnectRecord> &);
+ void enqueue(DIVERIFY_queue&, Uint32 senderData, Uint64 gci);
+ void dequeue(DIVERIFY_queue&, ApiConnectRecord &);
DIVERIFY_queue c_diverify_queue[1];
Uint32 c_diverify_queue_cnt;
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2011-05-18 10:48:58 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2011-05-25 07:58:32 +0000
@@ -1298,6 +1298,8 @@ void Dbdih::execREAD_CONFIG_REQ(Signal*
ndbrequireErr(!ndb_mgm_get_int_parameter(p, CFG_DIH_API_CONNECT,
&capiConnectFileSize),
NDBD_EXIT_INVALID_CONFIG);
+ capiConnectFileSize++; // Increase by 1...so that srsw queue never gets full
+
ndbrequireErr(!ndb_mgm_get_int_parameter(p, CFG_DIH_FRAG_CONNECT,
&cfragstoreFileSize),
NDBD_EXIT_INVALID_CONFIG);
@@ -9004,7 +9006,7 @@ void Dbdih::execDIGETNODESREQ(Signal* si
Uint32 fragId, newFragId = RNIL;
DiGetNodesConf * const conf = (DiGetNodesConf *)&signal->theData[0];
TabRecord* regTabDesc = tabRecord;
- EmulatedJamBuffer * jambuf = jamBuffer();
+ EmulatedJamBuffer * jambuf = * (EmulatedJamBuffer**)(req->jamBuffer);
thrjamEntry(jambuf);
ptrCheckGuard(tabPtr, ttabFileSize, regTabDesc);
@@ -9202,62 +9204,61 @@ void Dbdih::initialiseFragstore()
}//for
}//Dbdih::initialiseFragstore()
+#ifndef NDB_HAVE_RMB
+#define rmb() do { } while (0)
+#endif
+
+#ifndef NDB_HAVE_WMB
+#define wmb() do { } while (0)
+#endif
+
inline
bool
Dbdih::isEmpty(const DIVERIFY_queue & q)
{
- return q.cverifyQueueCounter == 0;
+ return q.cfirstVerifyQueue == q.clastVerifyQueue;
}
inline
void
-Dbdih::enqueue(DIVERIFY_queue & q, Ptr<ApiConnectRecord> conRecord)
+Dbdih::enqueue(DIVERIFY_queue & q, Uint32 senderData, Uint64 gci)
{
- Uint32 first = q.cfirstVerifyQueue;
Uint32 last = q.clastVerifyQueue;
- Uint32 count = q.cverifyQueueCounter;
ApiConnectRecord * apiConnectRecord = q.apiConnectRecord;
- Ptr<ApiConnectRecord> tmp;
- tmp.i = last;
- if (last != RNIL)
- {
- tmp.i = last;
- ptrCheckGuard(tmp, capiConnectFileSize, apiConnectRecord);
- tmp.p->nextApi = conRecord.i;
+ apiConnectRecord[last].senderData = senderData;
+ apiConnectRecord[last].apiGci = gci;
+ wmb();
+ if (last + 1 == capiConnectFileSize)
+ {
+ q.clastVerifyQueue = 0;
}
else
{
- ndbassert(count == 0);
- first = conRecord.i;
+ q.clastVerifyQueue = last + 1;
}
- q.cfirstVerifyQueue = first;
- q.clastVerifyQueue = conRecord.i;
- q.cverifyQueueCounter = count + 1;
+ assert(q.clastVerifyQueue != q.cfirstVerifyQueue);
}
inline
void
-Dbdih::dequeue(DIVERIFY_queue & q, Ptr<ApiConnectRecord> & conRecord)
+Dbdih::dequeue(DIVERIFY_queue & q, ApiConnectRecord & conRecord)
{
Uint32 first = q.cfirstVerifyQueue;
- Uint32 last = q.clastVerifyQueue;
- Uint32 count = q.cverifyQueueCounter;
ApiConnectRecord * apiConnectRecord = q.apiConnectRecord;
- conRecord.i = first;
- ptrCheckGuard(conRecord, capiConnectFileSize, apiConnectRecord);
- Uint32 next = conRecord.p->nextApi;
- if (first == last)
- {
- ndbrequire(next == RNIL);
- ndbassert(count == 1);
- last = RNIL;
- }
- ndbrequire(count > 0);
- q.cfirstVerifyQueue = next;
- q.clastVerifyQueue = last;
- q.cverifyQueueCounter = count - 1;
+ rmb();
+ conRecord.senderData = apiConnectRecord[first].senderData;
+ conRecord.apiGci = apiConnectRecord[first].apiGci;
+
+ if (first + 1 == capiConnectFileSize)
+ {
+ q.cfirstVerifyQueue = 0;
+ }
+ else
+ {
+ q.cfirstVerifyQueue = first + 1;
+ }
}
/*
@@ -9273,7 +9274,7 @@ Dbdih::dequeue(DIVERIFY_queue & q, Ptr<A
*/
void Dbdih::execDIVERIFYREQ(Signal* signal)
{
- EmulatedJamBuffer * jambuf = jamBuffer();
+ EmulatedJamBuffer * jambuf = * (EmulatedJamBuffer**)(signal->theData+2);
thrjamEntry(jambuf);
if ((getBlockCommit() == false) &&
isEmpty(c_diverify_queue[0]))
@@ -9295,15 +9296,8 @@ void Dbdih::execDIVERIFYREQ(Signal* sign
// Since we are blocked we need to put this operation last in the verify
// queue to ensure that operation starts up in the correct order.
/*-------------------------------------------------------------------------*/
- ApiConnectRecordPtr localApiConnectptr;
DIVERIFY_queue & q = c_diverify_queue[0];
-
- localApiConnectptr.i = signal->theData[0];
- ptrCheckGuard(localApiConnectptr, capiConnectFileSize, q.apiConnectRecord);
- localApiConnectptr.p->apiGci = m_micro_gcp.m_new_gci;
- localApiConnectptr.p->nextApi = RNIL;
-
- enqueue(q, localApiConnectptr);
+ enqueue(q, signal->theData[0], m_micro_gcp.m_new_gci);
emptyverificbuffer(signal, false);
signal->theData[3] = 1; // Indicate no immediate return
return;
@@ -14730,12 +14724,12 @@ void Dbdih::emptyverificbuffer(Signal* s
jam();
return;
}//if
- ApiConnectRecordPtr localApiConnectptr;
+ ApiConnectRecord localApiConnect;
if(getBlockCommit() == false){
jam();
- dequeue(c_diverify_queue[0], localApiConnectptr);
- ndbrequire(localApiConnectptr.p->apiGci <= m_micro_gcp.m_current_gci);
- signal->theData[0] = localApiConnectptr.i;
+ dequeue(c_diverify_queue[0], localApiConnect);
+ ndbrequire(localApiConnect.apiGci <= m_micro_gcp.m_current_gci);
+ signal->theData[0] = localApiConnect.senderData;
signal->theData[1] = (Uint32)(m_micro_gcp.m_current_gci >> 32);
signal->theData[2] = (Uint32)(m_micro_gcp.m_current_gci & 0xFFFFFFFF);
signal->theData[3] = 0;
@@ -15464,7 +15458,8 @@ void Dbdih::initialiseRecordsLab(Signal*
{
refresh_watch_dog();
ptrAss(apiConnectptr, c_diverify_queue[i].apiConnectRecord);
- apiConnectptr.p->nextApi = RNIL;
+ apiConnectptr.p->senderData = RNIL;
+ apiConnectptr.p->apiGci = ~(Uint64)0;
}//for
}
jam();
@@ -17255,10 +17250,11 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal
c_nodeStartMaster.blockLcp, c_nodeStartMaster.blockGcp, c_nodeStartMaster.wait);
for (Uint32 i = 0; i < c_diverify_queue_cnt; i++)
{
- infoEvent("[ %u : cfirstVerifyQueue = 0x%.8x, cverifyQueueCounter = %u ]",
+ infoEvent("[ %u : cfirstVerifyQueue = %u clastVerifyQueue = %u sz: %u]",
i,
c_diverify_queue[i].cfirstVerifyQueue,
- c_diverify_queue[i].cverifyQueueCounter);
+ c_diverify_queue[i].clastVerifyQueue,
+ capiConnectFileSize);
}
infoEvent("cgcpOrderBlocked = %d",
cgcpOrderBlocked);
=== modified file 'storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp 2011-05-13 08:38:01 +0000
+++ b/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp 2011-05-25 06:58:00 +0000
@@ -3682,6 +3682,7 @@ Dbspj::getNodes(Signal* signal, BuildKey
req->tableId = tableId;
req->hashValue = dst.hashInfo[1];
req->distr_key_indicator = 0; // userDefinedPartitioning not supported!
+ * (EmulatedJamBuffer**)req->jamBuffer = jamBuffer();
#if 1
EXECUTE_DIRECT(DBDIH, GSN_DIGETNODESREQ, signal,
=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-05-03 13:48:54 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-05-25 06:58:00 +0000
@@ -3188,6 +3188,7 @@ void Dbtc::tckeyreq050Lab(Signal* signal
req->tableId = Ttableref;
req->hashValue = TdistrHashValue;
req->distr_key_indicator = regCachePtr->distributionKeyIndicator;
+ * (EmulatedJamBuffer**)req->jamBuffer = jamBuffer();
/*-------------------------------------------------------------*/
/* FOR EFFICIENCY REASONS WE AVOID THE SIGNAL SENDING HERE AND */
@@ -4878,7 +4879,9 @@ void Dbtc::diverify010Lab(Signal* signal
* CONNECTIONS AND THEN WHEN ALL DIVERIFYCONF HAVE BEEN RECEIVED THE
* COMMIT MESSAGE CAN BE SENT TO ALL INVOLVED PARTS.
*---------------------------------------------------------------------*/
- EXECUTE_DIRECT(DBDIH, GSN_DIVERIFYREQ, signal, 1);
+ * (EmulatedJamBuffer**)(signal->theData+2) = jamBuffer();
+ EXECUTE_DIRECT(DBDIH, GSN_DIVERIFYREQ, signal,
+ 2 + sizeof(void*)/sizeof(Uint32));
if (signal->theData[3] == 0) {
execDIVERIFYCONF(signal);
}
@@ -10871,7 +10874,7 @@ void Dbtc::execDIH_SCAN_TAB_CONF(Signal*
req->tableId = tabPtr.i;
req->hashValue = cachePtr.p->distributionKey;
req->distr_key_indicator = tabPtr.p->get_user_defined_partitioning();
-
+ * (EmulatedJamBuffer**)req->jamBuffer = jamBuffer();
EXECUTE_DIRECT(DBDIH, GSN_DIGETNODESREQ, signal,
DiGetNodesReq::SignalLength);
UintR TerrorIndicator = signal->theData[0];
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.0 branch (jonas:4411 to 4413) | Jonas Oreland | 25 May |