Commit 80c1bddd authored by unknown's avatar unknown

merge


ndb/include/transporter/TransporterRegistry.hpp:
  Auto merged
ndb/src/kernel/main.cpp:
  Auto merged
parents bf0b3493 63b36352
...@@ -3,18 +3,24 @@ ...@@ -3,18 +3,24 @@
1 host, 1 ndbd, api co-hosted 1 host, 1 ndbd, api co-hosted
results in 1000 rows / sec results in 1000 rows / sec
wo/reset bounds w/ rb wo/reset bounds w/ rb
4.1-read committed a) 4.9 b) 7.4 4.1-read committed a) 4.9 b) 7.4
4.1-read hold lock c) 4.7 d) 6.7 4.1-read hold lock c) 4.7 d) 6.7
wl2077-read committed 6.4 (+30%) 10.8 (+45%) wl2077-read committed 6.4 (+30%) 10.8 (+45%)
wl2077-read hold lock 4.6 (-1%) 6.7 (+ 0%) wl2077-read hold lock 4.6 (-1%) 6.7 (+ 0%)
-- Comparision e) 5.0-ndb batch read committed f) 50' (+680%) g) 50' (+360%)
serial pk: 10.9' 5.0-ndb batch read hold lock h) 12' (+160%) i) 13' (+79%)
batched (1000): 59'
serial uniq index: 8.4' shm-mem read committed (cmp. wl2077) a) 9.5' (+48%) b) 14' (+30%)
batched (1000): 33' read hold lock c) 6.7' (+45%) d) 9.8' (+46%)
-- Comparision e) shm
serial pk: 10.9' 20' (+83%)
batched (1000): 59' 62' (+5%)
serial uniq index: 8.4' 14' (+66%)
batched (1000): 33' 36' (+9%)
index range (1000): 186' index range (1000): 186'
---- ----
...@@ -25,6 +31,8 @@ b) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 2 -q 1 T1 ...@@ -25,6 +31,8 @@ b) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 2 -q 1 T1
c) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 0 T1 c) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 0 T1
d) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 1 T1 d) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 1 T1
e) testReadPerf -i 25 -c 0 -d 0 T1 e) testReadPerf -i 25 -c 0 -d 0 T1
f) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 3 -q 0 -m 1000 -i 10 T1
g) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 3 -q 1 -m 1000 -i 10 T1
--- music join 1db-co 2db-co --- music join 1db-co 2db-co
...@@ -33,3 +41,8 @@ e) testReadPerf -i 25 -c 0 -d 0 T1 ...@@ -33,3 +41,8 @@ e) testReadPerf -i 25 -c 0 -d 0 T1
wl2077 12s 14s wl2077 12s 14s
wl2077 wo/ blobs 1.2s (-30%) 2.5s (-22%) wl2077 wo/ blobs 1.2s (-30%) 2.5s (-22%)
pekka-blob-fix 1.3s
shm 1.2s 2.0s
shm wo/ blobs 1.1s 2.0s
...@@ -87,6 +87,7 @@ public: ...@@ -87,6 +87,7 @@ public:
*/ */
class TransporterRegistry { class TransporterRegistry {
friend class OSE_Receiver; friend class OSE_Receiver;
friend class SHM_Transporter;
friend class Transporter; friend class Transporter;
friend class TransporterService; friend class TransporterService;
public: public:
...@@ -312,6 +313,8 @@ private: ...@@ -312,6 +313,8 @@ private:
Uint32 poll_TCP(Uint32 timeOutMillis); Uint32 poll_TCP(Uint32 timeOutMillis);
Uint32 poll_SCI(Uint32 timeOutMillis); Uint32 poll_SCI(Uint32 timeOutMillis);
Uint32 poll_SHM(Uint32 timeOutMillis); Uint32 poll_SHM(Uint32 timeOutMillis);
int m_shm_own_pid;
}; };
#endif // Define of TransporterRegistry_H #endif // Define of TransporterRegistry_H
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <InputStream.hpp> #include <InputStream.hpp>
#include <OutputStream.hpp> #include <OutputStream.hpp>
extern int g_shm_pid;
SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
const char *lHostName, const char *lHostName,
const char *rHostName, const char *rHostName,
...@@ -52,6 +54,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, ...@@ -52,6 +54,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
#ifdef DEBUG_TRANSPORTER #ifdef DEBUG_TRANSPORTER
printf("shm key (%d - %d) = %d\n", lNodeId, rNodeId, shmKey); printf("shm key (%d - %d) = %d\n", lNodeId, rNodeId, shmKey);
#endif #endif
m_signal_threshold = 4096;
} }
SHM_Transporter::~SHM_Transporter(){ SHM_Transporter::~SHM_Transporter(){
...@@ -182,42 +185,6 @@ SHM_Transporter::setupBuffers(){ ...@@ -182,42 +185,6 @@ SHM_Transporter::setupBuffers(){
#endif #endif
} }
#if 0
SendStatus
SHM_Transporter::prepareSend(const SignalHeader * const signalHeader,
Uint8 prio,
const Uint32 * const signalData,
const LinearSegmentPtr ptr[3],
bool force){
if(isConnected()){
const Uint32 lenBytes = m_packer.getMessageLength(signalHeader, ptr);
Uint32 * insertPtr = (Uint32 *)writer->getWritePtr(lenBytes);
if(insertPtr != 0){
m_packer.pack(insertPtr, prio, signalHeader, signalData, ptr);
/**
* Do funky membar stuff
*/
writer->updateWritePtr(lenBytes);
return SEND_OK;
} else {
// NdbSleep_MilliSleep(3);
//goto tryagain;
return SEND_BUFFER_FULL;
}
}
return SEND_DISCONNECTED;
}
#endif
bool bool
SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
{ {
...@@ -247,10 +214,18 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) ...@@ -247,10 +214,18 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
} }
// Send ok to client // Send ok to client
s_output.println("shm server 1 ok"); s_output.println("shm server 1 ok: %d",
m_transporter_registry.m_shm_own_pid);
// Wait for ok from client // Wait for ok from client
if (s_input.gets(buf, 256) == 0) { if (s_input.gets(buf, 256) == 0)
{
NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false);
}
if(sscanf(buf, "shm client 1 ok: %d", &m_remote_pid) != 1)
{
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false); DBUG_RETURN(false);
} }
...@@ -289,6 +264,12 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) ...@@ -289,6 +264,12 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
DBUG_RETURN(false); DBUG_RETURN(false);
} }
if(sscanf(buf, "shm server 1 ok: %d", &m_remote_pid) != 1)
{
NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false);
}
// Create // Create
if(!_shmSegCreated){ if(!_shmSegCreated){
if (!ndb_shm_get()) { if (!ndb_shm_get()) {
...@@ -313,10 +294,11 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) ...@@ -313,10 +294,11 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
} }
// Send ok to server // Send ok to server
s_output.println("shm client 1 ok"); s_output.println("shm client 1 ok: %d",
m_transporter_registry.m_shm_own_pid);
int r= connect_common(sockfd); int r= connect_common(sockfd);
if (r) { if (r) {
// Wait for ok from server // Wait for ok from server
if (s_input.gets(buf, 256) == 0) { if (s_input.gets(buf, 256) == 0) {
...@@ -344,18 +326,33 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd) ...@@ -344,18 +326,33 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
return false; return false;
} }
if(!setupBuffersDone) { if(!setupBuffersDone)
{
setupBuffers(); setupBuffers();
setupBuffersDone=true; setupBuffersDone=true;
} }
if(setupBuffersDone) { if(setupBuffersDone)
{
NdbSleep_MilliSleep(m_timeOutMillis); NdbSleep_MilliSleep(m_timeOutMillis);
if(*serverStatusFlag == 1 && *clientStatusFlag == 1) if(*serverStatusFlag == 1 && *clientStatusFlag == 1)
{
m_last_signal = 0;
return true; return true;
}
} }
DBUG_PRINT("error", ("Failed to set up buffers to node %d", DBUG_PRINT("error", ("Failed to set up buffers to node %d",
remoteNodeId)); remoteNodeId));
return false; return false;
} }
void
SHM_Transporter::doSend()
{
if(m_last_signal)
{
m_last_signal = 0;
kill(m_remote_pid, SIGUSR1);
}
}
...@@ -47,18 +47,25 @@ public: ...@@ -47,18 +47,25 @@ public:
* SHM destructor * SHM destructor
*/ */
virtual ~SHM_Transporter(); virtual ~SHM_Transporter();
/** /**
* Do initialization * Do initialization
*/ */
bool initTransporter(); bool initTransporter();
Uint32 * getWritePtr(Uint32 lenBytes, Uint32 prio){ Uint32 * getWritePtr(Uint32 lenBytes, Uint32 prio)
{
return (Uint32 *)writer->getWritePtr(lenBytes); return (Uint32 *)writer->getWritePtr(lenBytes);
} }
void updateWritePtr(Uint32 lenBytes, Uint32 prio){ void updateWritePtr(Uint32 lenBytes, Uint32 prio)
{
writer->updateWritePtr(lenBytes); writer->updateWritePtr(lenBytes);
m_last_signal += lenBytes;
if(m_last_signal >= m_signal_threshold)
{
doSend();
}
} }
void getReceivePtr(Uint32 ** ptr, Uint32 ** eod){ void getReceivePtr(Uint32 ** ptr, Uint32 ** eod){
...@@ -123,28 +130,36 @@ protected: ...@@ -123,28 +130,36 @@ protected:
*/ */
void setupBuffers(); void setupBuffers();
/**
* doSend (i.e signal receiver)
*/
void doSend();
int m_remote_pid;
Uint32 m_last_signal;
Uint32 m_signal_threshold;
private: private:
bool _shmSegCreated; bool _shmSegCreated;
bool _attached; bool _attached;
bool m_connected; bool m_connected;
key_t shmKey; key_t shmKey;
volatile Uint32 * serverStatusFlag; volatile Uint32 * serverStatusFlag;
volatile Uint32 * clientStatusFlag; volatile Uint32 * clientStatusFlag;
bool setupBuffersDone; bool setupBuffersDone;
#ifdef NDB_WIN32 #ifdef NDB_WIN32
HANDLE hFileMapping; HANDLE hFileMapping;
#else #else
int shmId; int shmId;
#endif #endif
int shmSize; int shmSize;
char * shmBuf; char * shmBuf;
SHM_Reader * reader; SHM_Reader * reader;
SHM_Writer * writer; SHM_Writer * writer;
/** /**
* @return - True if the reader has data to read on its segment. * @return - True if the reader has data to read on its segment.
*/ */
......
...@@ -1265,10 +1265,6 @@ Backup::createAttributeMask(TablePtr tabPtr, ...@@ -1265,10 +1265,6 @@ Backup::createAttributeMask(TablePtr tabPtr,
jam(); jam();
AttributePtr attr; AttributePtr attr;
table.attributes.getPtr(attr, i); table.attributes.getPtr(attr, i);
if(attr.p->data.key != 0){
jam();
continue;
}
mask.set(i); mask.set(i);
} }
} }
...@@ -2954,12 +2950,9 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) ...@@ -2954,12 +2950,9 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len)
tabPtr.p->schemaVersion = tmpTab.TableVersion; tabPtr.p->schemaVersion = tmpTab.TableVersion;
tabPtr.p->noOfAttributes = tmpTab.NoOfAttributes; tabPtr.p->noOfAttributes = tmpTab.NoOfAttributes;
tabPtr.p->noOfKeys = tmpTab.NoOfKeyAttr;
tabPtr.p->noOfNull = 0; tabPtr.p->noOfNull = 0;
tabPtr.p->noOfVariable = 0; // Computed while iterating over attribs tabPtr.p->noOfVariable = 0; // Computed while iterating over attribs
tabPtr.p->sz_FixedKeys = 0; // Computed while iterating over attribs
tabPtr.p->sz_FixedAttributes = 0; // Computed while iterating over attribs tabPtr.p->sz_FixedAttributes = 0; // Computed while iterating over attribs
tabPtr.p->variableKeyId = RNIL; // Computed while iterating over attribs
tabPtr.p->triggerIds[0] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[0] = ILLEGAL_TRIGGER_ID;
tabPtr.p->triggerIds[1] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[1] = ILLEGAL_TRIGGER_ID;
tabPtr.p->triggerIds[2] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[2] = ILLEGAL_TRIGGER_ID;
...@@ -2994,7 +2987,6 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) ...@@ -2994,7 +2987,6 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len)
attrPtr.p->data.nullable = tmp.AttributeNullableFlag; attrPtr.p->data.nullable = tmp.AttributeNullableFlag;
attrPtr.p->data.fixed = (tmp.AttributeArraySize != 0); attrPtr.p->data.fixed = (tmp.AttributeArraySize != 0);
attrPtr.p->data.key = tmp.AttributeKeyFlag;
attrPtr.p->data.sz32 = sz32; attrPtr.p->data.sz32 = sz32;
/** /**
...@@ -3002,50 +2994,26 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) ...@@ -3002,50 +2994,26 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len)
* 1) Fixed * 1) Fixed
* 2) Nullable * 2) Nullable
* 3) Variable * 3) Variable
* 4) Fixed key
* 5) Variable key
*/ */
if(attrPtr.p->data.key == false) { if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == false) {
jam(); jam();
attrPtr.p->data.offset = tabPtr.p->sz_FixedAttributes;
if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == false) { tabPtr.p->sz_FixedAttributes += sz32;
jam(); }//if
attrPtr.p->data.offset = tabPtr.p->sz_FixedAttributes;
tabPtr.p->sz_FixedAttributes += sz32; if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == true) {
}//if
if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == true) {
jam();
attrPtr.p->data.offset = 0;
attrPtr.p->data.offsetNull = tabPtr.p->noOfNull;
tabPtr.p->noOfNull++;
tabPtr.p->noOfVariable++;
}//if
if(attrPtr.p->data.fixed == false) {
jam();
tabPtr.p->noOfVariable++;
ndbrequire(0);
}//if
} else if(attrPtr.p->data.key == true) {
jam(); jam();
ndbrequire(attrPtr.p->data.nullable == false); attrPtr.p->data.offset = 0;
if(attrPtr.p->data.fixed == true) { // Fixed key attrPtr.p->data.offsetNull = tabPtr.p->noOfNull;
jam(); tabPtr.p->noOfNull++;
tabPtr.p->sz_FixedKeys += sz32; tabPtr.p->noOfVariable++;
}//if }//if
if(attrPtr.p->data.fixed == false) { // Variable key if(attrPtr.p->data.fixed == false) {
jam(); jam();
attrPtr.p->data.offset = 0; tabPtr.p->noOfVariable++;
tabPtr.p->noOfVariable++; ndbrequire(0);
ndbrequire(tabPtr.p->variableKeyId == RNIL); // Only one variable key
tabPtr.p->variableKeyId = attrPtr.i;
ndbrequire(0);
}//if
}//if }//if
it.next(); // Move Past EndOfAttribute it.next(); // Move Past EndOfAttribute
...@@ -3355,7 +3323,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) ...@@ -3355,7 +3323,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal)
Table & table = * tabPtr.p; Table & table = * tabPtr.p;
ScanFragReq * req = (ScanFragReq *)signal->getDataPtrSend(); ScanFragReq * req = (ScanFragReq *)signal->getDataPtrSend();
const Uint32 parallelism = 16; const Uint32 parallelism = 16;
const Uint32 attrLen = 5 + table.noOfAttributes - table.noOfKeys; const Uint32 attrLen = 5 + table.noOfAttributes;
req->senderData = filePtr.i; req->senderData = filePtr.i;
req->resultRef = reference(); req->resultRef = reference();
...@@ -3366,7 +3334,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) ...@@ -3366,7 +3334,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal)
req->tableId = table.tableId; req->tableId = table.tableId;
ScanFragReq::setLockMode(req->requestInfo, 0); ScanFragReq::setLockMode(req->requestInfo, 0);
ScanFragReq::setHoldLockFlag(req->requestInfo, 0); ScanFragReq::setHoldLockFlag(req->requestInfo, 0);
ScanFragReq::setKeyinfoFlag(req->requestInfo, 1); ScanFragReq::setKeyinfoFlag(req->requestInfo, 0);
ScanFragReq::setAttrLen(req->requestInfo,attrLen); ScanFragReq::setAttrLen(req->requestInfo,attrLen);
req->transId1 = 0; req->transId1 = 0;
req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8); req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
...@@ -3381,7 +3349,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) ...@@ -3381,7 +3349,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal)
signal->theData[2] = (BACKUP << 20) + (getOwnNodeId() << 8); signal->theData[2] = (BACKUP << 20) + (getOwnNodeId() << 8);
// Return all // Return all
signal->theData[3] = table.noOfAttributes - table.noOfKeys; signal->theData[3] = table.noOfAttributes;
signal->theData[4] = 0; signal->theData[4] = 0;
signal->theData[5] = 0; signal->theData[5] = 0;
signal->theData[6] = 0; signal->theData[6] = 0;
...@@ -3393,10 +3361,6 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) ...@@ -3393,10 +3361,6 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal)
jam(); jam();
AttributePtr attr; AttributePtr attr;
table.attributes.getPtr(attr, i); table.attributes.getPtr(attr, i);
if(attr.p->data.key != 0) {
jam();
continue;
}//if
AttributeHeader::init(&signal->theData[dataPos], i, 0); AttributeHeader::init(&signal->theData[dataPos], i, 0);
dataPos++; dataPos++;
...@@ -3506,64 +3470,19 @@ Backup::execTRANSID_AI(Signal* signal) ...@@ -3506,64 +3470,19 @@ Backup::execTRANSID_AI(Signal* signal)
} }
} }
void
Backup::execKEYINFO20(Signal* signal)
{
jamEntry();
const Uint32 filePtrI = signal->theData[0];
const Uint32 keyLen = signal->theData[1];
//const Uint32 scanInfo = signal->theData[2];
//const Uint32 transId1 = signal->theData[3];
//const Uint32 transId2 = signal->theData[4];
const Uint32 dataLen = signal->length() - 5;
BackupFilePtr filePtr;
c_backupFilePool.getPtr(filePtr, filePtrI);
OperationRecord & op = filePtr.p->operation;
/**
* Unpack data
*/
ndbrequire(keyLen == dataLen);
const Uint32 * src = &signal->theData[5];
const Uint32 klFixed = op.getFixedKeySize();
ndbrequire(keyLen >= klFixed);
Uint32 * dst = op.newKey();
memcpy(dst, src, klFixed << 2);
const Uint32 szLeft = (keyLen - klFixed);
if(szLeft > 0) {
jam();
src += klFixed;
dst = op.newVariableKey(szLeft);
memcpy(dst, src, (szLeft << 2));
ndbrequire(0);
}//if
if(op.finished()){
jam();
op.newRecord(op.dst);
}
}
void void
Backup::OperationRecord::init(const TablePtr & ptr) Backup::OperationRecord::init(const TablePtr & ptr)
{ {
tablePtr = ptr.i; tablePtr = ptr.i;
noOfAttributes = (ptr.p->noOfAttributes - ptr.p->noOfKeys) + 1; noOfAttributes = ptr.p->noOfAttributes;
variableKeyId = ptr.p->variableKeyId;
sz_Bitmask = (ptr.p->noOfNull + 31) >> 5; sz_Bitmask = (ptr.p->noOfNull + 31) >> 5;
sz_FixedKeys = ptr.p->sz_FixedKeys;
sz_FixedAttribs = ptr.p->sz_FixedAttributes; sz_FixedAttribs = ptr.p->sz_FixedAttributes;
if(ptr.p->noOfVariable == 0) { if(ptr.p->noOfVariable == 0) {
jam(); jam();
maxRecordSize = 1 + sz_Bitmask + sz_FixedKeys + sz_FixedAttribs; maxRecordSize = 1 + sz_Bitmask + sz_FixedAttribs;
} else { } else {
jam(); jam();
maxRecordSize = maxRecordSize =
......
...@@ -76,7 +76,6 @@ protected: ...@@ -76,7 +76,6 @@ protected:
*/ */
void execSCAN_HBREP(Signal* signal); void execSCAN_HBREP(Signal* signal);
void execTRANSID_AI(Signal* signal); void execTRANSID_AI(Signal* signal);
void execKEYINFO20(Signal* signal);
void execSCAN_FRAGREF(Signal* signal); void execSCAN_FRAGREF(Signal* signal);
void execSCAN_FRAGCONF(Signal* signal); void execSCAN_FRAGCONF(Signal* signal);
...@@ -172,8 +171,8 @@ public: ...@@ -172,8 +171,8 @@ public:
struct Data { struct Data {
Uint8 nullable; Uint8 nullable;
Uint8 fixed; Uint8 fixed;
Uint8 key; Uint8 unused;
Uint8 unused; Uint8 unused2;
Uint32 sz32; // No of 32 bit words Uint32 sz32; // No of 32 bit words
Uint32 offset; // Relative DataFixedAttributes/DataFixedKeys Uint32 offset; // Relative DataFixedAttributes/DataFixedKeys
Uint32 offsetNull; // In NullBitmask Uint32 offsetNull; // In NullBitmask
...@@ -199,12 +198,9 @@ public: ...@@ -199,12 +198,9 @@ public:
Uint32 frag_mask; Uint32 frag_mask;
Uint32 tableType; Uint32 tableType;
Uint32 noOfNull; Uint32 noOfNull;
Uint32 noOfKeys;
Uint32 noOfAttributes; Uint32 noOfAttributes;
Uint32 noOfVariable; Uint32 noOfVariable;
Uint32 sz_FixedKeys;
Uint32 sz_FixedAttributes; Uint32 sz_FixedAttributes;
Uint32 variableKeyId;
Uint32 triggerIds[3]; Uint32 triggerIds[3];
bool triggerAllocated[3]; bool triggerAllocated[3];
...@@ -224,7 +220,6 @@ public: ...@@ -224,7 +220,6 @@ public:
* Once per table * Once per table
*/ */
void init(const TablePtr & ptr); void init(const TablePtr & ptr);
inline Uint32 getFixedKeySize() const { return sz_FixedKeys; }
/** /**
* Once per fragment * Once per fragment
...@@ -247,23 +242,19 @@ public: ...@@ -247,23 +242,19 @@ public:
/** /**
* Per attribute * Per attribute
*/ */
Uint32 * newKey();
void nullAttribute(Uint32 nullOffset); void nullAttribute(Uint32 nullOffset);
Uint32 * newNullable(Uint32 attrId, Uint32 sz); Uint32 * newNullable(Uint32 attrId, Uint32 sz);
Uint32 * newAttrib(Uint32 offset, Uint32 sz); Uint32 * newAttrib(Uint32 offset, Uint32 sz);
Uint32 * newVariable(Uint32 id, Uint32 sz); Uint32 * newVariable(Uint32 id, Uint32 sz);
Uint32 * newVariableKey(Uint32 sz);
private: private:
Uint32* base; Uint32* base;
Uint32* dst_Length; Uint32* dst_Length;
Uint32* dst_Bitmask; Uint32* dst_Bitmask;
Uint32* dst_FixedKeys;
Uint32* dst_FixedAttribs; Uint32* dst_FixedAttribs;
BackupFormat::DataFile::VariableData* dst_VariableData; BackupFormat::DataFile::VariableData* dst_VariableData;
Uint32 noOfAttributes; // No of Attributes Uint32 noOfAttributes; // No of Attributes
Uint32 variableKeyId; // Id of variable key
Uint32 attrLeft; // No of attributes left Uint32 attrLeft; // No of attributes left
Uint32 opNoDone; Uint32 opNoDone;
...@@ -289,7 +280,6 @@ public: ...@@ -289,7 +280,6 @@ public:
* sizes of part * sizes of part
*/ */
Uint32 sz_Bitmask; Uint32 sz_Bitmask;
Uint32 sz_FixedKeys;
Uint32 sz_FixedAttribs; Uint32 sz_FixedAttribs;
public: public:
...@@ -628,7 +618,6 @@ Backup::OperationRecord::newRecord(Uint32 * p){ ...@@ -628,7 +618,6 @@ Backup::OperationRecord::newRecord(Uint32 * p){
base = p; base = p;
dst_Length = p; p += 1; dst_Length = p; p += 1;
dst_Bitmask = p; p += sz_Bitmask; dst_Bitmask = p; p += sz_Bitmask;
dst_FixedKeys = p; p += sz_FixedKeys;
dst_FixedAttribs = p; p += sz_FixedAttribs; dst_FixedAttribs = p; p += sz_FixedAttribs;
dst_VariableData = (BackupFormat::DataFile::VariableData*)p; dst_VariableData = (BackupFormat::DataFile::VariableData*)p;
BitmaskImpl::clear(sz_Bitmask, dst_Bitmask); BitmaskImpl::clear(sz_Bitmask, dst_Bitmask);
...@@ -645,14 +634,6 @@ Backup::OperationRecord::newAttrib(Uint32 offset, Uint32 sz){ ...@@ -645,14 +634,6 @@ Backup::OperationRecord::newAttrib(Uint32 offset, Uint32 sz){
return dst; return dst;
} }
inline
Uint32 *
Backup::OperationRecord::newKey(){
attrLeft --;
attrSzLeft = 0;
return dst_FixedKeys;
}
inline inline
void void
Backup::OperationRecord::nullAttribute(Uint32 offsetNull){ Backup::OperationRecord::nullAttribute(Uint32 offsetNull){
...@@ -691,21 +672,6 @@ Backup::OperationRecord::newVariable(Uint32 id, Uint32 sz){ ...@@ -691,21 +672,6 @@ Backup::OperationRecord::newVariable(Uint32 id, Uint32 sz){
return dst; return dst;
} }
inline
Uint32 *
Backup::OperationRecord::newVariableKey(Uint32 sz){
attrLeft--;
attrSzLeft = 0;
attrSzTotal += sz;
dst = &dst_VariableData->Data[0];
dst_VariableData->Sz = htonl(sz);
dst_VariableData->Id = htonl(variableKeyId);
dst_VariableData = (BackupFormat::DataFile::VariableData *)(dst + sz);
return dst;
}
inline inline
bool bool
Backup::OperationRecord::finished(){ Backup::OperationRecord::finished(){
...@@ -713,7 +679,7 @@ Backup::OperationRecord::finished(){ ...@@ -713,7 +679,7 @@ Backup::OperationRecord::finished(){
return false; return false;
} }
opLen += attrSzTotal + sz_FixedKeys; opLen += attrSzTotal;
opNoDone++; opNoDone++;
scanStop = dst = (Uint32 *)dst_VariableData; scanStop = dst = (Uint32 *)dst_VariableData;
......
...@@ -126,7 +126,6 @@ Backup::Backup(const Configuration & conf) : ...@@ -126,7 +126,6 @@ Backup::Backup(const Configuration & conf) :
addRecSignal(GSN_SCAN_HBREP, &Backup::execSCAN_HBREP); addRecSignal(GSN_SCAN_HBREP, &Backup::execSCAN_HBREP);
addRecSignal(GSN_TRANSID_AI, &Backup::execTRANSID_AI); addRecSignal(GSN_TRANSID_AI, &Backup::execTRANSID_AI);
addRecSignal(GSN_KEYINFO20, &Backup::execKEYINFO20);
addRecSignal(GSN_SCAN_FRAGREF, &Backup::execSCAN_FRAGREF); addRecSignal(GSN_SCAN_FRAGREF, &Backup::execSCAN_FRAGREF);
addRecSignal(GSN_SCAN_FRAGCONF, &Backup::execSCAN_FRAGCONF); addRecSignal(GSN_SCAN_FRAGCONF, &Backup::execSCAN_FRAGCONF);
......
...@@ -83,7 +83,7 @@ static bool transformConnection(InitConfigFileParser::Context & ctx, const char ...@@ -83,7 +83,7 @@ static bool transformConnection(InitConfigFileParser::Context & ctx, const char
static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *); static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *);
static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *); static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *);
static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *); static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *);
static bool fixShmkey(InitConfigFileParser::Context & ctx, const char *); static bool fixShmKey(InitConfigFileParser::Context & ctx, const char *);
static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *); static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *);
static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *); static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *);
static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *); static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *);
...@@ -132,13 +132,15 @@ ConfigInfo::m_SectionRules[] = { ...@@ -132,13 +132,15 @@ ConfigInfo::m_SectionRules[] = {
{ "TCP", fixHostname, "HostName2" }, { "TCP", fixHostname, "HostName2" },
{ "SCI", fixHostname, "HostName1" }, { "SCI", fixHostname, "HostName1" },
{ "SCI", fixHostname, "HostName2" }, { "SCI", fixHostname, "HostName2" },
{ "SHM", fixHostname, "HostName1" },
{ "SHM", fixHostname, "HostName2" },
{ "OSE", fixHostname, "HostName1" }, { "OSE", fixHostname, "HostName1" },
{ "OSE", fixHostname, "HostName2" }, { "OSE", fixHostname, "HostName2" },
{ "TCP", fixPortNumber, 0 }, // has to come after fixHostName { "TCP", fixPortNumber, 0 }, // has to come after fixHostName
{ "SHM", fixPortNumber, 0 }, // has to come after fixHostName { "SHM", fixPortNumber, 0 }, // has to come after fixHostName
{ "SCI", fixPortNumber, 0 }, // has to come after fixHostName { "SCI", fixPortNumber, 0 }, // has to come after fixHostName
//{ "SHM", fixShmKey, 0 }, { "SHM", fixShmKey, 0 },
/** /**
* fixExtConnection must be after fixNodeId * fixExtConnection must be after fixNodeId
...@@ -169,6 +171,8 @@ ConfigInfo::m_SectionRules[] = { ...@@ -169,6 +171,8 @@ ConfigInfo::m_SectionRules[] = {
{ "TCP", checkTCPConstraints, "HostName2" }, { "TCP", checkTCPConstraints, "HostName2" },
{ "SCI", checkTCPConstraints, "HostName1" }, { "SCI", checkTCPConstraints, "HostName1" },
{ "SCI", checkTCPConstraints, "HostName2" }, { "SCI", checkTCPConstraints, "HostName2" },
{ "SHM", checkTCPConstraints, "HostName1" },
{ "SHM", checkTCPConstraints, "HostName2" },
{ "*", checkMandatory, 0 }, { "*", checkMandatory, 0 },
...@@ -1688,16 +1692,27 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1688,16 +1692,27 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0, 0 }, 0, 0 },
{ {
CFG_CONNECTION_NODE_1, CFG_CONNECTION_HOSTNAME_1,
"NodeId1", "HostName1",
"SHM", "SHM",
"Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", "Name/IP of computer on one side of the connection",
ConfigInfo::CI_USED, ConfigInfo::CI_INTERNAL,
false, false,
ConfigInfo::CI_STRING, ConfigInfo::CI_STRING,
MANDATORY, UNDEFINED,
0, 0 }, 0, 0 },
{
CFG_CONNECTION_HOSTNAME_2,
"HostName2",
"SHM",
"Name/IP of computer on one side of the connection",
ConfigInfo::CI_INTERNAL,
false,
ConfigInfo::CI_STRING,
UNDEFINED,
0, 0 },
{ {
CFG_CONNECTION_SERVER_PORT, CFG_CONNECTION_SERVER_PORT,
"PortNumber", "PortNumber",
...@@ -1710,6 +1725,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1710,6 +1725,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0", "0",
STR_VALUE(MAX_INT_RNIL) }, STR_VALUE(MAX_INT_RNIL) },
{
CFG_CONNECTION_NODE_1,
"NodeId1",
"SHM",
"Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
ConfigInfo::USED,
false,
ConfigInfo::STRING,
MANDATORY,
0, 0 },
{ {
CFG_CONNECTION_NODE_2, CFG_CONNECTION_NODE_2,
"NodeId2", "NodeId2",
...@@ -2948,7 +2974,13 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2948,7 +2974,13 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){
require(ctx.m_currentSection->get(buf, &id)); require(ctx.m_currentSection->get(buf, &id));
const Properties * node; const Properties * node;
require(ctx.m_config->get("Node", id, &node)); if(!ctx.m_config->get("Node", id, &node))
{
ctx.reportError("Unknown node: \"%d\" specified in connection "
"[%s] starting at line: %d",
id, ctx.fname, ctx.m_sectionLineno);
return false;
}
const char * hostname; const char * hostname;
require(node->get("HostName", &hostname)); require(node->get("HostName", &hostname));
...@@ -3026,15 +3058,32 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -3026,15 +3058,32 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
<< "per connection, please remove from config. " << "per connection, please remove from config. "
<< "Will be changed to " << port << endl; << "Will be changed to " << port << endl;
ctx.m_currentSection->put("PortNumber", port, true); ctx.m_currentSection->put("PortNumber", port, true);
} else }
else
{
ctx.m_currentSection->put("PortNumber", port); ctx.m_currentSection->put("PortNumber", port);
}
DBUG_PRINT("info", ("connection %d-%d port %d host %s", DBUG_PRINT("info", ("connection %d-%d port %d host %s",
id1, id2, port, hostname.c_str())); id1, id2, port, hostname.c_str()));
DBUG_RETURN(true); DBUG_RETURN(true);
} }
static
bool
fixShmKey(InitConfigFileParser::Context & ctx, const char *)
{
Uint32 id1= 0, id2= 0, key= 0;
require(ctx.m_currentSection->get("NodeId1", &id1));
require(ctx.m_currentSection->get("NodeId2", &id2));
if(ctx.m_currentSection->get("ShmKey", &key))
return true;
key= (id1 > id2 ? id1 << 16 | id2 : id2 << 16 | id1);
ctx.m_currentSection->put("ShmKey", key);
return true;
}
/** /**
* DB Node rule: Check various constraints * DB Node rule: Check various constraints
*/ */
......
...@@ -192,14 +192,15 @@ RestoreMetaData::readGCPEntry() { ...@@ -192,14 +192,15 @@ RestoreMetaData::readGCPEntry() {
return true; return true;
} }
TableS::TableS(NdbTableImpl* tableImpl) TableS::TableS(Uint32 version, NdbTableImpl* tableImpl)
: m_dictTable(tableImpl) : m_dictTable(tableImpl)
{ {
m_dictTable = tableImpl; m_dictTable = tableImpl;
m_noOfNullable = m_nullBitmaskSize = 0; m_noOfNullable = m_nullBitmaskSize = 0;
m_auto_val_id= ~(Uint32)0; m_auto_val_id= ~(Uint32)0;
m_max_auto_val= 0; m_max_auto_val= 0;
backupVersion = version;
for (int i = 0; i < tableImpl->getNoOfColumns(); i++) for (int i = 0; i < tableImpl->getNoOfColumns(); i++)
createAttr(tableImpl->getColumn(i)); createAttr(tableImpl->getColumn(i));
} }
...@@ -226,11 +227,10 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, Uint32 len) ...@@ -226,11 +227,10 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, Uint32 len)
debug << "parseTableInfo " << tableImpl->getName() << " done" << endl; debug << "parseTableInfo " << tableImpl->getName() << " done" << endl;
TableS * table = new TableS(tableImpl); TableS * table = new TableS(m_fileHeader.NdbVersion, tableImpl);
if(table == NULL) { if(table == NULL) {
return false; return false;
} }
table->setBackupVersion(m_fileHeader.NdbVersion);
debug << "Parsed table id " << table->getTableId() << endl; debug << "Parsed table id " << table->getTableId() << endl;
debug << "Parsed table #attr " << table->getNoOfAttributes() << endl; debug << "Parsed table #attr " << table->getNoOfAttributes() << endl;
...@@ -699,12 +699,12 @@ void TableS::createAttr(NdbDictionary::Column *column) ...@@ -699,12 +699,12 @@ void TableS::createAttr(NdbDictionary::Column *column)
if (d->m_column->getAutoIncrement()) if (d->m_column->getAutoIncrement())
m_auto_val_id= d->attrId; m_auto_val_id= d->attrId;
if(d->m_column->getPrimaryKey() /* && not variable */) if(d->m_column->getPrimaryKey() && backupVersion <= MAKE_VERSION(4,1,7))
{ {
m_fixedKeys.push_back(d); m_fixedKeys.push_back(d);
return; return;
} }
if(!d->m_column->getNullable()) if(!d->m_column->getNullable())
{ {
m_fixedAttribs.push_back(d); m_fixedAttribs.push_back(d);
......
...@@ -140,7 +140,7 @@ class TableS { ...@@ -140,7 +140,7 @@ class TableS {
public: public:
class NdbDictionary::Table* m_dictTable; class NdbDictionary::Table* m_dictTable;
TableS (class NdbTableImpl* dictTable); TableS (Uint32 version, class NdbTableImpl* dictTable);
~TableS(); ~TableS();
Uint32 getTableId() const { Uint32 getTableId() const {
......
...@@ -247,11 +247,18 @@ main(int argc, char** argv) ...@@ -247,11 +247,18 @@ main(int argc, char** argv)
ndbout << "Failed to read " << metaData.getFilename() << endl << endl; ndbout << "Failed to read " << metaData.getFilename() << endl << endl;
return -1; return -1;
} }
const BackupFormat::FileHeader & tmp = metaData.getFileHeader();
const Uint32 version = tmp.NdbVersion;
ndbout << "Ndb version in backup files: "
<< getVersionString(version, 0) << endl;
/** /**
* check wheater we can restore the backup (right version). * check wheater we can restore the backup (right version).
*/ */
int res = metaData.loadContent(); int res = metaData.loadContent();
if (res == 0) if (res == 0)
{ {
ndbout_c("Restore: Failed to load content"); ndbout_c("Restore: Failed to load content");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment