From 630636a27cb902dd365e93ec66e980d154401673 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Mon, 4 Dec 2006 10:06:51 +0100 Subject: [PATCH 01/40] ndb - bug#24166 SR crash if table with disk with hidden primary key... --- storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index 677eff53559..1786ec3421b 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -784,7 +784,7 @@ int Dbtup::updateAttributes(KeyReqStruct *req_struct, req_struct->m_tuple_ptr->m_header_bits |= Tuple_header::DISK_PART; memcpy(req_struct->m_tuple_ptr->get_disk_ref_ptr(regTabPtr), inBuffer+inBufIndex+1, sz << 2); - inBufIndex += 1 + sz; + req_struct->in_buf_index = inBufIndex += 1 + sz; } else { From d720cd2786455d3821a0744c732b40874e480aa8 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 5 Dec 2006 15:10:56 +0100 Subject: [PATCH 02/40] ndb - bug#24664 1) run lcp snapshot for both MM and DD tables (so I dont have to change restore to use WRITE) 2) fix >= and > bug in lcp skip/keep handling 3) very cool test prog for this :-) --- .../kernel/signaldata/BackupContinueB.hpp | 3 +- storage/ndb/src/kernel/blocks/ERROR_codes.txt | 5 +- .../ndb/src/kernel/blocks/backup/Backup.cpp | 35 ++++++++++ .../src/kernel/blocks/dbtup/DbtupCommit.cpp | 33 +++++----- .../ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 40 +++++------ storage/ndb/test/ndbapi/testSystemRestart.cpp | 66 +++++++++++++++++++ .../ndb/test/run-test/daily-basic-tests.txt | 4 ++ 7 files changed, 145 insertions(+), 41 deletions(-) diff --git a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp index 9035c6f8140..1ca7aee7937 100644 --- a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp @@ -33,7 +33,8 @@ private: BUFFER_FULL_FRAG_COMPLETE = 3, BUFFER_FULL_META = 4, BACKUP_FRAGMENT_INFO = 5, - RESET_DISK_SPEED_COUNTER = 6 + RESET_DISK_SPEED_COUNTER = 6, + ZDELAY_SCAN_NEXT = 7 }; }; diff --git a/storage/ndb/src/kernel/blocks/ERROR_codes.txt b/storage/ndb/src/kernel/blocks/ERROR_codes.txt index 56b5b8e4bc8..83aa1183772 100644 --- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt @@ -8,7 +8,7 @@ Next DBDICT 6007 Next DBDIH 7178 Next DBTC 8039 Next CMVMI 9000 -Next BACKUP 10036 +Next BACKUP 10038 Next DBUTIL 11002 Next DBTUX 12008 Next SUMA 13001 @@ -425,6 +425,9 @@ Backup Stuff: 10034: define backup reply error 10035: Fail to allocate buffers +10036: Halt backup for table >= 2 +10037: Resume backup (from 10036) + 11001: Send UTIL_SEQUENCE_REF (in master) 5028: Crash when receiving LQHKEYREQ (in non-master) diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index d6b557424e7..1f16200f52c 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -356,6 +356,25 @@ Backup::execCONTINUEB(Signal* signal) GetTabInfoReq::SignalLength, JBB); return; } + case BackupContinueB::ZDELAY_SCAN_NEXT: + if (ERROR_INSERTED(10036)) + { + jam(); + sendSignalWithDelay(BACKUP_REF, GSN_CONTINUEB, signal, 300, + signal->getLength()); + return; + } + else + { + jam(); + CLEAR_ERROR_INSERT_VALUE; + ndbout_c("Resuming backup"); + memmove(signal->theData, signal->theData + 1, + 4*ScanFragNextReq::SignalLength); + sendSignal(DBLQH_REF, GSN_SCAN_NEXTREQ, signal, + ScanFragNextReq::SignalLength, JBB); + return ; + } default: ndbrequire(0); }//switch @@ -3920,6 +3939,22 @@ Backup::checkScan(Signal* signal, BackupFilePtr filePtr) req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8); req->batch_size_rows= 16; req->batch_size_bytes= 0; + + if (ERROR_INSERTED(10036) && + filePtr.p->tableId >= 2 && + filePtr.p->operation.noOfRecords > 0) + { + ndbout_c("halting backup for table %d fragment: %d after %d records", + filePtr.p->tableId, + filePtr.p->fragmentNo, + filePtr.p->operation.noOfRecords); + memmove(signal->theData+1, signal->theData, + 4*ScanFragNextReq::SignalLength); + signal->theData[0] = BackupContinueB::ZDELAY_SCAN_NEXT; + sendSignalWithDelay(BACKUP_REF, GSN_CONTINUEB, signal, + 300, 1+ScanFragNextReq::SignalLength); + return; + } if(ERROR_INSERTED(10032)) sendSignalWithDelay(DBLQH_REF, GSN_SCAN_NEXTREQ, signal, 100, ScanFragNextReq::SignalLength); diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index fc3419e694a..7cb792985e8 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -152,10 +152,10 @@ void Dbtup::initOpConnection(Operationrec* regOperPtr) static inline bool -operator>=(const Local_key& key1, const Local_key& key2) +operator>(const Local_key& key1, const Local_key& key2) { return key1.m_page_no > key2.m_page_no || - (key1.m_page_no == key2.m_page_no && key1.m_page_idx >= key2.m_page_idx); + (key1.m_page_no == key2.m_page_no && key1.m_page_idx > key2.m_page_idx); } void @@ -187,7 +187,7 @@ Dbtup::dealloc_tuple(Signal* signal, Local_key rowid = regOperPtr->m_tuple_location; Local_key scanpos = scanOp.p->m_scanPos.m_key; rowid.m_page_no = page->frag_page_id; - if (rowid >= scanpos) + if (rowid > scanpos) { extra_bits = Tuple_header::LCP_KEEP; // Note REMOVE FREE ptr->m_operation_ptr_i = lcp_keep_list; @@ -215,6 +215,7 @@ Dbtup::commit_operation(Signal* signal, { ndbassert(regOperPtr->op_struct.op_type != ZDELETE); + Uint32 lcpScan_ptr_i= regFragPtr->m_lcp_scan_op; Uint32 save= tuple_ptr->m_operation_ptr_i; Uint32 bits= tuple_ptr->m_header_bits; @@ -264,7 +265,6 @@ Dbtup::commit_operation(Signal* signal, Local_key key; memcpy(&key, copy->get_disk_ref_ptr(regTabPtr), sizeof(Local_key)); Uint32 logfile_group_id= regFragPtr->m_logfile_group_id; - Uint32 lcpScan_ptr_i= regFragPtr->m_lcp_scan_op; PagePtr diskPagePtr = *(PagePtr*)&m_pgman.m_ptr; ndbassert(diskPagePtr.p->m_page_no == key.m_page_no); @@ -273,19 +273,6 @@ Dbtup::commit_operation(Signal* signal, if(copy_bits & Tuple_header::DISK_ALLOC) { disk_page_alloc(signal, regTabPtr, regFragPtr, &key, diskPagePtr, gci); - - if(lcpScan_ptr_i != RNIL) - { - ScanOpPtr scanOp; - c_scanOpPool.getPtr(scanOp, lcpScan_ptr_i); - Local_key rowid = regOperPtr->m_tuple_location; - Local_key scanpos = scanOp.p->m_scanPos.m_key; - rowid.m_page_no = pagePtr.p->frag_page_id; - if(rowid >= scanpos) - { - copy_bits |= Tuple_header::LCP_SKIP; - } - } } if(regTabPtr->m_attributes[DD].m_no_of_varsize == 0) @@ -312,6 +299,18 @@ Dbtup::commit_operation(Signal* signal, copy_bits |= Tuple_header::DISK_PART; } + if(lcpScan_ptr_i != RNIL) + { + ScanOpPtr scanOp; + c_scanOpPool.getPtr(scanOp, lcpScan_ptr_i); + Local_key rowid = regOperPtr->m_tuple_location; + Local_key scanpos = scanOp.p->m_scanPos.m_key; + rowid.m_page_no = pagePtr.p->frag_page_id; + if(rowid > scanpos) + { + copy_bits |= Tuple_header::LCP_SKIP; + } + } Uint32 clear= Tuple_header::ALLOC | Tuple_header::FREE | diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index 38156d1453c..1cb7c5132a7 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -54,8 +54,7 @@ Dbtup::execACC_SCANREQ(Signal* signal) // flags Uint32 bits = 0; - if (!AccScanReq::getLcpScanFlag(req->requestInfo) || - tablePtr.p->m_no_of_disk_attributes == 0) + if (!AccScanReq::getLcpScanFlag(req->requestInfo)) { // seize from pool and link to per-fragment list LocalDLList list(c_scanOpPool, frag.m_scanList); @@ -1052,24 +1051,21 @@ Dbtup::execLCP_FRAG_ORD(Signal* signal) tablePtr.i = req->tableId; ptrCheckGuard(tablePtr, cnoOfTablerec, tablerec); - if(tablePtr.p->m_no_of_disk_attributes) - { - jam(); - FragrecordPtr fragPtr; - Uint32 fragId = req->fragmentId; - fragPtr.i = RNIL; - getFragmentrec(fragPtr, fragId, tablePtr.p); - ndbrequire(fragPtr.i != RNIL); - Fragrecord& frag = *fragPtr.p; - - ndbrequire(frag.m_lcp_scan_op == RNIL && c_lcp_scan_op != RNIL); - frag.m_lcp_scan_op = c_lcp_scan_op; - ScanOpPtr scanPtr; - c_scanOpPool.getPtr(scanPtr, frag.m_lcp_scan_op); - ndbrequire(scanPtr.p->m_fragPtrI == RNIL); - scanPtr.p->m_fragPtrI = fragPtr.i; - - scanFirst(signal, scanPtr); - scanPtr.p->m_state = ScanOp::First; - } + jam(); + FragrecordPtr fragPtr; + Uint32 fragId = req->fragmentId; + fragPtr.i = RNIL; + getFragmentrec(fragPtr, fragId, tablePtr.p); + ndbrequire(fragPtr.i != RNIL); + Fragrecord& frag = *fragPtr.p; + + ndbrequire(frag.m_lcp_scan_op == RNIL && c_lcp_scan_op != RNIL); + frag.m_lcp_scan_op = c_lcp_scan_op; + ScanOpPtr scanPtr; + c_scanOpPool.getPtr(scanPtr, frag.m_lcp_scan_op); + ndbrequire(scanPtr.p->m_fragPtrI == RNIL); + scanPtr.p->m_fragPtrI = fragPtr.i; + + scanFirst(signal, scanPtr); + scanPtr.p->m_state = ScanOp::First; } diff --git a/storage/ndb/test/ndbapi/testSystemRestart.cpp b/storage/ndb/test/ndbapi/testSystemRestart.cpp index 8a0100ff3e4..569b5bc3e48 100644 --- a/storage/ndb/test/ndbapi/testSystemRestart.cpp +++ b/storage/ndb/test/ndbapi/testSystemRestart.cpp @@ -1162,6 +1162,64 @@ runBug21536(NDBT_Context* ctx, NDBT_Step* step) return result; } +int +runBug24664(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + NdbRestarter restarter; + Ndb* pNdb = GETNDB(step); + const Uint32 nodeCount = restarter.getNumDbNodes(); + + int records = ctx->getNumRecords(); + UtilTransactions utilTrans(*ctx->getTab()); + HugoTransactions hugoTrans(*ctx->getTab()); + + int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP }; + int dump[] = { DumpStateOrd::DihStartLcpImmediately }; + + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 }; + NdbLogEventHandle handle = + ndb_mgm_create_logevent_handle(restarter.handle, filter); + + struct ndb_logevent event; + + do { + CHECK(restarter.dumpStateAllNodes(args, 1) == 0); + CHECK(restarter.dumpStateAllNodes(dump, 1) == 0); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointStarted); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointCompleted); + + if (hugoTrans.loadTable(GETNDB(step), records) != 0){ + return NDBT_FAILED; + } + + restarter.insertErrorInAllNodes(10036); // Hang LCP + CHECK(restarter.dumpStateAllNodes(dump, 1) == 0); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointStarted); + NdbSleep_SecSleep(3); + CHECK(utilTrans.clearTable(pNdb, records) == 0); + if (hugoTrans.loadTable(GETNDB(step), records) != 0){ + return NDBT_FAILED; + } + + restarter.insertErrorInAllNodes(10037); // Resume LCP + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointCompleted); + + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_GlobalCheckpointCompleted); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_GlobalCheckpointCompleted); + restarter.restartAll(false, false, true); + CHECK(restarter.waitClusterStarted() == 0); + } while(false); + + return result; +} + NDBT_TESTSUITE(testSystemRestart); TESTCASE("SR1", "Basic system restart test. Focus on testing restart from REDO log.\n" @@ -1334,6 +1392,14 @@ TESTCASE("Bug21536", STEP(runBug21536); FINALIZER(runClearTable); } +TESTCASE("Bug24664", + "Check handling of LCP skip/keep") +{ + INITIALIZER(runWaitStarted); + INITIALIZER(runClearTable); + STEP(runBug24664); + FINALIZER(runClearTable); +} NDBT_TESTSUITE_END(testSystemRestart); int main(int argc, const char** argv){ diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index 89921203e8c..295ef4c3667 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -752,6 +752,10 @@ max-time: 300 cmd: testNodeRestart args: -n Bug24543 T1 +max-time: 1500 +cmd: testSystemRestart +args: -n Bug24664 + # OLD FLEX max-time: 500 cmd: flexBench From cade1966316eab3d5eb7c2135fe95087f148d71b Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 5 Dec 2006 15:52:31 +0100 Subject: [PATCH 03/40] New result --- mysql-test/r/ps_7ndb.result | 314 ++++++++++++++++++------------------ 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 9e0577f8ae2..432a07df9d0 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1409,7 +1409,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1522,7 +1522,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'NDB' ; @@ -1758,31 +1758,31 @@ NULL as const12, @arg12 as param12, show create table t5 ; Table Create Table t5 CREATE TABLE `t5` ( - `const01` int(1) NOT NULL default '0', - `param01` bigint(20) default NULL, - `const02` decimal(2,1) NOT NULL default '0.0', - `param02` decimal(65,30) default NULL, - `const03` double NOT NULL default '0', - `param03` double default NULL, - `const04` varchar(3) NOT NULL default '', + `const01` int(1) NOT NULL DEFAULT '0', + `param01` bigint(20) DEFAULT NULL, + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', + `param02` decimal(65,30) DEFAULT NULL, + `const03` double NOT NULL DEFAULT '0', + `param03` double DEFAULT NULL, + `const04` varchar(3) NOT NULL DEFAULT '', `param04` longtext, - `const05` varbinary(3) NOT NULL default '', + `const05` varbinary(3) NOT NULL DEFAULT '', `param05` longblob, - `const06` varchar(10) NOT NULL default '', + `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, - `const07` date default NULL, + `const07` date DEFAULT NULL, `param07` longblob, - `const08` varchar(19) NOT NULL default '', + `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, - `const09` datetime default NULL, + `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` int(10) NOT NULL default '0', - `param10` bigint(20) default NULL, - `const11` int(4) default NULL, - `param11` bigint(20) default NULL, - `const12` binary(0) default NULL, - `param12` bigint(20) default NULL, - `param13` decimal(65,30) default NULL, + `const10` int(10) NOT NULL DEFAULT '0', + `param10` bigint(20) DEFAULT NULL, + `const11` int(4) DEFAULT NULL, + `param11` bigint(20) DEFAULT NULL, + `const12` binary(0) DEFAULT NULL, + `param12` bigint(20) DEFAULT NULL, + `param13` decimal(65,30) DEFAULT NULL, `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 @@ -1912,26 +1912,26 @@ def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 def @arg11 253 67 6 Y 128 30 63 def @arg12 253 67 6 Y 128 30 63 -def @arg13 253 8192 10 Y 128 31 63 -def @arg14 253 8192 19 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 8 Y 128 31 63 +def @arg13 253 16777216 10 Y 128 31 63 +def @arg14 253 16777216 19 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 8 Y 128 31 63 def @arg17 253 20 4 Y 128 0 63 def @arg18 253 20 1 Y 128 0 63 def @arg19 253 20 1 Y 128 0 63 -def @arg20 253 8192 1 Y 0 31 8 -def @arg21 253 8192 10 Y 0 31 8 -def @arg22 253 8192 30 Y 0 31 8 -def @arg23 253 8192 8 Y 128 31 63 -def @arg24 253 8192 8 Y 0 31 8 -def @arg25 253 8192 4 Y 128 31 63 -def @arg26 253 8192 4 Y 0 31 8 -def @arg27 253 8192 10 Y 128 31 63 -def @arg28 253 8192 10 Y 0 31 8 -def @arg29 253 8192 8 Y 128 31 63 -def @arg30 253 8192 8 Y 0 31 8 -def @arg31 253 8192 3 Y 0 31 8 -def @arg32 253 8192 6 Y 0 31 8 +def @arg20 253 16777216 1 Y 0 31 8 +def @arg21 253 16777216 10 Y 0 31 8 +def @arg22 253 16777216 30 Y 0 31 8 +def @arg23 253 16777216 8 Y 128 31 63 +def @arg24 253 16777216 8 Y 0 31 8 +def @arg25 253 16777216 4 Y 128 31 63 +def @arg26 253 16777216 4 Y 0 31 8 +def @arg27 253 16777216 10 Y 128 31 63 +def @arg28 253 16777216 10 Y 0 31 8 +def @arg29 253 16777216 8 Y 128 31 63 +def @arg30 253 16777216 8 Y 0 31 8 +def @arg31 253 16777216 3 Y 0 31 8 +def @arg32 253 16777216 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -1959,26 +1959,26 @@ def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 def @arg11 253 67 0 Y 128 30 63 def @arg12 253 67 0 Y 128 30 63 -def @arg13 253 8192 0 Y 128 31 63 -def @arg14 253 8192 0 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 0 Y 128 31 63 +def @arg13 253 16777216 0 Y 128 31 63 +def @arg14 253 16777216 0 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 0 Y 128 31 63 def @arg17 253 20 0 Y 128 0 63 def @arg18 253 20 0 Y 128 0 63 def @arg19 253 20 0 Y 128 0 63 -def @arg20 253 8192 0 Y 0 31 8 -def @arg21 253 8192 0 Y 0 31 8 -def @arg22 253 8192 0 Y 0 31 8 -def @arg23 253 8192 0 Y 128 31 63 -def @arg24 253 8192 0 Y 0 31 8 -def @arg25 253 8192 0 Y 128 31 63 -def @arg26 253 8192 0 Y 0 31 8 -def @arg27 253 8192 0 Y 128 31 63 -def @arg28 253 8192 0 Y 0 31 8 -def @arg29 253 8192 0 Y 128 31 63 -def @arg30 253 8192 0 Y 0 31 8 -def @arg31 253 8192 0 Y 0 31 8 -def @arg32 253 8192 0 Y 0 31 8 +def @arg20 253 16777216 0 Y 0 31 8 +def @arg21 253 16777216 0 Y 0 31 8 +def @arg22 253 16777216 0 Y 0 31 8 +def @arg23 253 16777216 0 Y 128 31 63 +def @arg24 253 16777216 0 Y 0 31 8 +def @arg25 253 16777216 0 Y 128 31 63 +def @arg26 253 16777216 0 Y 0 31 8 +def @arg27 253 16777216 0 Y 128 31 63 +def @arg28 253 16777216 0 Y 0 31 8 +def @arg29 253 16777216 0 Y 128 31 63 +def @arg30 253 16777216 0 Y 0 31 8 +def @arg31 253 16777216 0 Y 0 31 8 +def @arg32 253 16777216 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2009,26 +2009,26 @@ def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 def @arg11 253 67 6 Y 128 30 63 def @arg12 253 67 6 Y 128 30 63 -def @arg13 253 8192 10 Y 128 31 63 -def @arg14 253 8192 19 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 8 Y 128 31 63 +def @arg13 253 16777216 10 Y 128 31 63 +def @arg14 253 16777216 19 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 8 Y 128 31 63 def @arg17 253 20 4 Y 128 0 63 def @arg18 253 20 1 Y 128 0 63 def @arg19 253 20 1 Y 128 0 63 -def @arg20 253 8192 1 Y 0 31 8 -def @arg21 253 8192 10 Y 0 31 8 -def @arg22 253 8192 30 Y 0 31 8 -def @arg23 253 8192 8 Y 128 31 63 -def @arg24 253 8192 8 Y 0 31 8 -def @arg25 253 8192 4 Y 128 31 63 -def @arg26 253 8192 4 Y 0 31 8 -def @arg27 253 8192 10 Y 128 31 63 -def @arg28 253 8192 10 Y 0 31 8 -def @arg29 253 8192 8 Y 128 31 63 -def @arg30 253 8192 8 Y 0 31 8 -def @arg31 253 8192 3 Y 0 31 8 -def @arg32 253 8192 6 Y 0 31 8 +def @arg20 253 16777216 1 Y 0 31 8 +def @arg21 253 16777216 10 Y 0 31 8 +def @arg22 253 16777216 30 Y 0 31 8 +def @arg23 253 16777216 8 Y 128 31 63 +def @arg24 253 16777216 8 Y 0 31 8 +def @arg25 253 16777216 4 Y 128 31 63 +def @arg26 253 16777216 4 Y 0 31 8 +def @arg27 253 16777216 10 Y 128 31 63 +def @arg28 253 16777216 10 Y 0 31 8 +def @arg29 253 16777216 8 Y 128 31 63 +def @arg30 253 16777216 8 Y 0 31 8 +def @arg31 253 16777216 3 Y 0 31 8 +def @arg32 253 16777216 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2049,26 +2049,26 @@ def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 def @arg11 253 67 0 Y 128 30 63 def @arg12 253 67 0 Y 128 30 63 -def @arg13 253 8192 0 Y 128 31 63 -def @arg14 253 8192 0 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 0 Y 128 31 63 +def @arg13 253 16777216 0 Y 128 31 63 +def @arg14 253 16777216 0 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 0 Y 128 31 63 def @arg17 253 20 0 Y 128 0 63 def @arg18 253 20 0 Y 128 0 63 def @arg19 253 20 0 Y 128 0 63 -def @arg20 253 8192 0 Y 0 31 8 -def @arg21 253 8192 0 Y 0 31 8 -def @arg22 253 8192 0 Y 0 31 8 -def @arg23 253 8192 0 Y 128 31 63 -def @arg24 253 8192 0 Y 0 31 8 -def @arg25 253 8192 0 Y 128 31 63 -def @arg26 253 8192 0 Y 0 31 8 -def @arg27 253 8192 0 Y 128 31 63 -def @arg28 253 8192 0 Y 0 31 8 -def @arg29 253 8192 0 Y 128 31 63 -def @arg30 253 8192 0 Y 0 31 8 -def @arg31 253 8192 0 Y 0 31 8 -def @arg32 253 8192 0 Y 0 31 8 +def @arg20 253 16777216 0 Y 0 31 8 +def @arg21 253 16777216 0 Y 0 31 8 +def @arg22 253 16777216 0 Y 0 31 8 +def @arg23 253 16777216 0 Y 128 31 63 +def @arg24 253 16777216 0 Y 0 31 8 +def @arg25 253 16777216 0 Y 128 31 63 +def @arg26 253 16777216 0 Y 0 31 8 +def @arg27 253 16777216 0 Y 128 31 63 +def @arg28 253 16777216 0 Y 0 31 8 +def @arg29 253 16777216 0 Y 128 31 63 +def @arg30 253 16777216 0 Y 0 31 8 +def @arg31 253 16777216 0 Y 0 31 8 +def @arg32 253 16777216 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2097,26 +2097,26 @@ def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 def @arg11 253 67 6 Y 128 30 63 def @arg12 253 67 6 Y 128 30 63 -def @arg13 253 8192 10 Y 128 31 63 -def @arg14 253 8192 19 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 8 Y 128 31 63 +def @arg13 253 16777216 10 Y 128 31 63 +def @arg14 253 16777216 19 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 8 Y 128 31 63 def @arg17 253 20 4 Y 128 0 63 def @arg18 253 20 1 Y 128 0 63 def @arg19 253 20 1 Y 128 0 63 -def @arg20 253 8192 1 Y 0 31 8 -def @arg21 253 8192 10 Y 0 31 8 -def @arg22 253 8192 30 Y 0 31 8 -def @arg23 253 8192 8 Y 128 31 63 -def @arg24 253 8192 8 Y 0 31 8 -def @arg25 253 8192 4 Y 128 31 63 -def @arg26 253 8192 4 Y 0 31 8 -def @arg27 253 8192 10 Y 128 31 63 -def @arg28 253 8192 10 Y 0 31 8 -def @arg29 253 8192 8 Y 128 31 63 -def @arg30 253 8192 8 Y 0 31 8 -def @arg31 253 8192 3 Y 0 31 8 -def @arg32 253 8192 6 Y 0 31 8 +def @arg20 253 16777216 1 Y 0 31 8 +def @arg21 253 16777216 10 Y 0 31 8 +def @arg22 253 16777216 30 Y 0 31 8 +def @arg23 253 16777216 8 Y 128 31 63 +def @arg24 253 16777216 8 Y 0 31 8 +def @arg25 253 16777216 4 Y 128 31 63 +def @arg26 253 16777216 4 Y 0 31 8 +def @arg27 253 16777216 10 Y 128 31 63 +def @arg28 253 16777216 10 Y 0 31 8 +def @arg29 253 16777216 8 Y 128 31 63 +def @arg30 253 16777216 8 Y 0 31 8 +def @arg31 253 16777216 3 Y 0 31 8 +def @arg32 253 16777216 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2141,26 +2141,26 @@ def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 def @arg11 253 67 0 Y 128 30 63 def @arg12 253 67 0 Y 128 30 63 -def @arg13 253 8192 0 Y 128 31 63 -def @arg14 253 8192 0 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 0 Y 128 31 63 +def @arg13 253 16777216 0 Y 128 31 63 +def @arg14 253 16777216 0 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 0 Y 128 31 63 def @arg17 253 20 0 Y 128 0 63 def @arg18 253 20 0 Y 128 0 63 def @arg19 253 20 0 Y 128 0 63 -def @arg20 253 8192 0 Y 0 31 8 -def @arg21 253 8192 0 Y 0 31 8 -def @arg22 253 8192 0 Y 0 31 8 -def @arg23 253 8192 0 Y 128 31 63 -def @arg24 253 8192 0 Y 0 31 8 -def @arg25 253 8192 0 Y 128 31 63 -def @arg26 253 8192 0 Y 0 31 8 -def @arg27 253 8192 0 Y 128 31 63 -def @arg28 253 8192 0 Y 0 31 8 -def @arg29 253 8192 0 Y 128 31 63 -def @arg30 253 8192 0 Y 0 31 8 -def @arg31 253 8192 0 Y 0 31 8 -def @arg32 253 8192 0 Y 0 31 8 +def @arg20 253 16777216 0 Y 0 31 8 +def @arg21 253 16777216 0 Y 0 31 8 +def @arg22 253 16777216 0 Y 0 31 8 +def @arg23 253 16777216 0 Y 128 31 63 +def @arg24 253 16777216 0 Y 0 31 8 +def @arg25 253 16777216 0 Y 128 31 63 +def @arg26 253 16777216 0 Y 0 31 8 +def @arg27 253 16777216 0 Y 128 31 63 +def @arg28 253 16777216 0 Y 0 31 8 +def @arg29 253 16777216 0 Y 128 31 63 +def @arg30 253 16777216 0 Y 0 31 8 +def @arg31 253 16777216 0 Y 0 31 8 +def @arg32 253 16777216 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2187,26 +2187,26 @@ def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 def @arg11 253 67 6 Y 128 30 63 def @arg12 253 67 6 Y 128 30 63 -def @arg13 253 8192 10 Y 128 31 63 -def @arg14 253 8192 19 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 8 Y 128 31 63 +def @arg13 253 16777216 10 Y 128 31 63 +def @arg14 253 16777216 19 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 8 Y 128 31 63 def @arg17 253 20 4 Y 128 0 63 def @arg18 253 20 1 Y 128 0 63 def @arg19 253 20 1 Y 128 0 63 -def @arg20 253 8192 1 Y 0 31 8 -def @arg21 253 8192 10 Y 0 31 8 -def @arg22 253 8192 30 Y 0 31 8 -def @arg23 253 8192 8 Y 128 31 63 -def @arg24 253 8192 8 Y 0 31 8 -def @arg25 253 8192 4 Y 128 31 63 -def @arg26 253 8192 4 Y 0 31 8 -def @arg27 253 8192 10 Y 128 31 63 -def @arg28 253 8192 10 Y 0 31 8 -def @arg29 253 8192 8 Y 128 31 63 -def @arg30 253 8192 8 Y 0 31 8 -def @arg31 253 8192 3 Y 0 31 8 -def @arg32 253 8192 6 Y 0 31 8 +def @arg20 253 16777216 1 Y 0 31 8 +def @arg21 253 16777216 10 Y 0 31 8 +def @arg22 253 16777216 30 Y 0 31 8 +def @arg23 253 16777216 8 Y 128 31 63 +def @arg24 253 16777216 8 Y 0 31 8 +def @arg25 253 16777216 4 Y 128 31 63 +def @arg26 253 16777216 4 Y 0 31 8 +def @arg27 253 16777216 10 Y 128 31 63 +def @arg28 253 16777216 10 Y 0 31 8 +def @arg29 253 16777216 8 Y 128 31 63 +def @arg30 253 16777216 8 Y 0 31 8 +def @arg31 253 16777216 3 Y 0 31 8 +def @arg32 253 16777216 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2225,26 +2225,26 @@ def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 def @arg11 253 67 0 Y 128 30 63 def @arg12 253 67 0 Y 128 30 63 -def @arg13 253 8192 0 Y 128 31 63 -def @arg14 253 8192 0 Y 128 31 63 -def @arg15 253 8192 19 Y 128 31 63 -def @arg16 253 8192 0 Y 128 31 63 +def @arg13 253 16777216 0 Y 128 31 63 +def @arg14 253 16777216 0 Y 128 31 63 +def @arg15 253 16777216 19 Y 128 31 63 +def @arg16 253 16777216 0 Y 128 31 63 def @arg17 253 20 0 Y 128 0 63 def @arg18 253 20 0 Y 128 0 63 def @arg19 253 20 0 Y 128 0 63 -def @arg20 253 8192 0 Y 0 31 8 -def @arg21 253 8192 0 Y 0 31 8 -def @arg22 253 8192 0 Y 0 31 8 -def @arg23 253 8192 0 Y 128 31 63 -def @arg24 253 8192 0 Y 0 31 8 -def @arg25 253 8192 0 Y 128 31 63 -def @arg26 253 8192 0 Y 0 31 8 -def @arg27 253 8192 0 Y 128 31 63 -def @arg28 253 8192 0 Y 0 31 8 -def @arg29 253 8192 0 Y 128 31 63 -def @arg30 253 8192 0 Y 0 31 8 -def @arg31 253 8192 0 Y 0 31 8 -def @arg32 253 8192 0 Y 0 31 8 +def @arg20 253 16777216 0 Y 0 31 8 +def @arg21 253 16777216 0 Y 0 31 8 +def @arg22 253 16777216 0 Y 0 31 8 +def @arg23 253 16777216 0 Y 128 31 63 +def @arg24 253 16777216 0 Y 0 31 8 +def @arg25 253 16777216 0 Y 128 31 63 +def @arg26 253 16777216 0 Y 0 31 8 +def @arg27 253 16777216 0 Y 128 31 63 +def @arg28 253 16777216 0 Y 0 31 8 +def @arg29 253 16777216 0 Y 128 31 63 +def @arg30 253 16777216 0 Y 0 31 8 +def @arg31 253 16777216 0 Y 0 31 8 +def @arg32 253 16777216 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; From 6d6fd5f7da1998ae7fe6fc9697264e30dfda50ef Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Wed, 6 Dec 2006 13:09:30 +0100 Subject: [PATCH 04/40] ndb - bug#22773 Fix correct log event on db-node disconnect --- ndb/src/mgmsrv/MgmtSrvr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 69c0286a1de..5c4a5ef7d17 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -1900,7 +1900,7 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete) m_started_nodes.push_back(nodeId); rep->setEventType(NDB_LE_Connected); } else { - rep->setEventType(NDB_LE_Connected); + rep->setEventType(NDB_LE_Disconnected); if(nfComplete) { DBUG_VOID_RETURN; From 4456144c58293799d9b1c80e2b6b04619d250613 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Wed, 6 Dec 2006 14:38:32 +0100 Subject: [PATCH 05/40] ndb - add support for periodic mem-reporting --- .../include/mgmapi/mgmapi_config_parameters.h | 2 ++ storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp | 1 + .../ndb/src/kernel/blocks/dbacc/DbaccMain.cpp | 28 ++++++++++++++----- storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 1 + .../ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 24 +++++++++++++--- storage/ndb/src/mgmsrv/ConfigInfo.cpp | 12 ++++++++ 6 files changed, 57 insertions(+), 11 deletions(-) diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index d1feaa1a7d3..f106f12d3f5 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -96,6 +96,8 @@ #define CFG_DB_CHECKPOINT_SPEED 164 #define CFG_DB_CHECKPOINT_SPEED_SR 165 +#define CFG_DB_MEMREPORT_FREQUENCY 166 + #define CFG_DB_SGA 198 /* super pool mem */ #define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */ diff --git a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp index f0c3dbc2866..100827508e7 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp +++ b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp @@ -1100,6 +1100,7 @@ private: }; Uint32 c_errorInsert3000_TableId; + Uint32 c_memusage_report_frequency; }; #endif diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 4b1e0ba7c55..7e3dee0d4e7 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -112,6 +112,7 @@ void Dbacc::execCONTINUEB(Signal* signal) } case ZREPORT_MEMORY_USAGE:{ jam(); + Uint32 cnt = signal->theData[1]; static int c_currentMemUsed = 0; int now = cpagesize ? (cnoOfAllocatedPages * 100)/cpagesize : 0; const int thresholds[] = { 99, 90, 80, 0}; @@ -125,14 +126,22 @@ void Dbacc::execCONTINUEB(Signal* signal) } } - if(now != c_currentMemUsed){ - reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1); + if(now != c_currentMemUsed || + (c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency)) + { + reportMemoryUsage(signal, + now > c_currentMemUsed ? 1 : + now < c_currentMemUsed ? -1 : 0); + cnt = 0; + c_currentMemUsed = now; + } + else + { + cnt ++; } - - c_currentMemUsed = now; - signal->theData[0] = ZREPORT_MEMORY_USAGE; - sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1); + signal->theData[1] = cnt; + sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2); return; } @@ -199,7 +208,8 @@ void Dbacc::execNDB_STTOR(Signal* signal) csystemRestart = ZFALSE; signal->theData[0] = ZREPORT_MEMORY_USAGE; - sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1); + signal->theData[1] = 0; + sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2); break; default: jam(); @@ -353,6 +363,10 @@ void Dbacc::execREAD_CONFIG_REQ(Signal* signal) initRecords(); ndbrestart1Lab(signal); + c_memusage_report_frequency = 0; + ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY, + &c_memusage_report_frequency); + tdata0 = 0; initialiseRecordsLab(signal, ref, senderData); return; diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 07ee55fce20..871c8b88fee 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -2571,6 +2571,7 @@ private: // Trigger variables Uint32 c_maxTriggersPerTable; + Uint32 c_memusage_report_frequency; Uint32 c_errorInsert4000TableId; Uint32 c_min_list_size[MAX_FREE_LIST + 1]; diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index 01326e6a353..fff557583be 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -169,6 +169,7 @@ void Dbtup::execCONTINUEB(Signal* signal) case ZREPORT_MEMORY_USAGE:{ ljam(); static int c_currentMemUsed = 0; + Uint32 cnt = signal->theData[1]; Uint32 tmp = c_page_pool.getSize(); int now = tmp ? (cnoOfAllocatedPages * 100)/tmp : 0; const int thresholds[] = { 100, 90, 80, 0 }; @@ -182,12 +183,22 @@ void Dbtup::execCONTINUEB(Signal* signal) } } - if(now != c_currentMemUsed){ - reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1); + if(now != c_currentMemUsed || + (c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency)) + { + reportMemoryUsage(signal, + now > c_currentMemUsed ? 1 : + now < c_currentMemUsed ? -1 : 0); + cnt = 0; c_currentMemUsed = now; + } + else + { + cnt++; } signal->theData[0] = ZREPORT_MEMORY_USAGE; - sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1); + signal->theData[1] = cnt; + sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2); return; } case ZBUILD_INDEX: @@ -337,6 +348,10 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) clastBitMask = 1; clastBitMask = clastBitMask << 31; + c_memusage_report_frequency = 0; + ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY, + &c_memusage_report_frequency); + initialiseRecordsLab(signal, 0, ref, senderData); }//Dbtup::execSIZEALT_REP() @@ -499,7 +514,8 @@ void Dbtup::execNDB_STTOR(Signal* signal) /* RESTART. */ /*****************************************/ signal->theData[0] = ZREPORT_MEMORY_USAGE; - sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1); + signal->theData[1] = 0; + sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1); break; default: ljam(); diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index 6d36662e516..00ee6a087ae 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -1298,6 +1298,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "0", "0", STR_VALUE(MAX_INT_RNIL) }, + + { + CFG_DB_MEMREPORT_FREQUENCY, + "MemReportFrequency", + DB_TOKEN, + "Frequency of mem reports in seconds, 0 = only when passing %-limits", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "0", + "0", + STR_VALUE(MAX_INT_RNIL) }, /*************************************************************************** * API From 3ab75d971d13b11a5148c407e9f6811d218e9838 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Thu, 7 Dec 2006 15:25:02 +0100 Subject: [PATCH 06/40] ndb - bug#21948 & bug#17605 fix alloc/free extent in undo log allow extent to be reused once a lcp is finished (instead of when next lcp starts) --- .../ndb/include/kernel/signaldata/Extent.hpp | 2 + .../ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 7 +- storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 45 +++- .../kernel/blocks/dbtup/DbtupDiskAlloc.cpp | 156 +++++++++++- .../kernel/blocks/dbtup/DbtupExecQuery.cpp | 6 +- .../ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 4 +- .../ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp | 231 +++++++++++++++--- storage/ndb/src/kernel/blocks/diskpage.hpp | 5 +- storage/ndb/src/kernel/blocks/lgman.cpp | 11 +- storage/ndb/src/kernel/blocks/print_file.cpp | 48 +++- storage/ndb/src/kernel/blocks/tsman.cpp | 171 ++++++------- storage/ndb/src/kernel/blocks/tsman.hpp | 54 +++- 12 files changed, 577 insertions(+), 163 deletions(-) diff --git a/storage/ndb/include/kernel/signaldata/Extent.hpp b/storage/ndb/include/kernel/signaldata/Extent.hpp index 86f45163be5..ea31b0968aa 100644 --- a/storage/ndb/include/kernel/signaldata/Extent.hpp +++ b/storage/ndb/include/kernel/signaldata/Extent.hpp @@ -74,6 +74,8 @@ struct FreeExtentReq { Local_key key; Uint32 table_id; Uint32 tablespace_id; + Uint32 lsn_hi; + Uint32 lsn_lo; } request; struct { diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index eff0910760e..1d0d6558e6d 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -11276,7 +11276,7 @@ void Dblqh::execLCP_PREPARE_REF(Signal* signal) /** * First fragment mean that last LCP is complete :-) */ - EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, signal->length()); + EXECUTE_DIRECT(TSMAN, GSN_LCP_FRAG_ORD, signal, signal->length()); jamEntry(); } @@ -11327,7 +11327,7 @@ void Dblqh::execLCP_PREPARE_CONF(Signal* signal) /** * First fragment mean that last LCP is complete :-) */ - EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, signal->length()); + EXECUTE_DIRECT(TSMAN, GSN_LCP_FRAG_ORD, signal, signal->length()); jamEntry(); } @@ -11611,6 +11611,9 @@ void Dblqh::completeLcpRoundLab(Signal* signal, Uint32 lcpId) sendSignal(LGMAN_REF, GSN_END_LCP_REQ, signal, EndLcpReq::SignalLength, JBB); + EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, EndLcpReq::SignalLength); + jamEntry(); + lcpPtr.i = 0; ptrAss(lcpPtr, lcpRecord); lcpPtr.p->m_outstanding = 3; diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 871c8b88fee..a27daf0a8ea 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -625,7 +625,8 @@ struct Fragrecord { DLList::Head m_scanList; - bool m_undo_complete; + enum { UC_LCP = 1, UC_CREATE = 2 }; + Uint32 m_undo_complete; Uint32 m_tablespace_id; Uint32 m_logfile_group_id; Disk_alloc_info m_disk_alloc_info; @@ -989,6 +990,9 @@ ArrayPool c_triggerPool; ,UNDO_UPDATE = File_formats::Undofile::UNDO_TUP_UPDATE ,UNDO_FREE = File_formats::Undofile::UNDO_TUP_FREE ,UNDO_CREATE = File_formats::Undofile::UNDO_TUP_CREATE + ,UNDO_DROP = File_formats::Undofile::UNDO_TUP_DROP + ,UNDO_ALLOC_EXTENT = File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT + ,UNDO_FREE_EXTENT = File_formats::Undofile::UNDO_TUP_FREE_EXTENT }; struct Alloc @@ -1021,6 +1025,30 @@ ArrayPool c_triggerPool; Uint32 m_table; Uint32 m_type_length; // 16 bit type, 16 bit length }; + + struct Drop + { + Uint32 m_table; + Uint32 m_type_length; // 16 bit type, 16 bit length + }; + + struct AllocExtent + { + Uint32 m_table; + Uint32 m_fragment; + Uint32 m_page_no; + Uint32 m_file_no; + Uint32 m_type_length; + }; + + struct FreeExtent + { + Uint32 m_table; + Uint32 m_fragment; + Uint32 m_page_no; + Uint32 m_file_no; + Uint32 m_type_length; + }; }; Extent_info_pool c_extent_pool; @@ -1420,7 +1448,7 @@ public: int nr_delete(Signal*, Uint32, Uint32 fragPtr, const Local_key*, Uint32 gci); void nr_delete_page_callback(Signal*, Uint32 op, Uint32 page); - void nr_delete_logbuffer_callback(Signal*, Uint32 op, Uint32 page); + void nr_delete_log_buffer_callback(Signal*, Uint32 op, Uint32 page); private: BLOCK_DEFINES(Dbtup); @@ -2345,9 +2373,10 @@ private: Uint32 fragId); - void releaseFragment(Signal* signal, Uint32 tableId); + void releaseFragment(Signal* signal, Uint32 tableId, Uint32); void drop_fragment_free_var_pages(Signal*); - void drop_fragment_free_exent(Signal*, TablerecPtr, FragrecordPtr, Uint32); + void drop_fragment_free_extent(Signal*, TablerecPtr, FragrecordPtr, Uint32); + void drop_fragment_free_extent_log_buffer_callback(Signal*, Uint32, Uint32); void drop_fragment_unmap_pages(Signal*, TablerecPtr, FragrecordPtr, Uint32); void drop_fragment_unmap_page_callback(Signal* signal, Uint32, Uint32); @@ -2631,6 +2660,9 @@ private: void disk_page_commit_callback(Signal*, Uint32 opPtrI, Uint32 page_id); void disk_page_log_buffer_callback(Signal*, Uint32 opPtrI, Uint32); + + void disk_page_alloc_extent_log_buffer_callback(Signal*, Uint32, Uint32); + void disk_page_free_extent_log_buffer_callback(Signal*, Uint32, Uint32); Uint64 disk_page_undo_alloc(Page*, const Local_key*, Uint32 sz, Uint32 gci, Uint32 logfile_group_id); @@ -2646,6 +2678,9 @@ private: void undo_createtable_callback(Signal* signal, Uint32 opPtrI, Uint32 unused); void undo_createtable_logsync_callback(Signal* signal, Uint32, Uint32); + void drop_table_log_buffer_callback(Signal*, Uint32, Uint32); + void drop_table_logsync_callback(Signal*, Uint32, Uint32); + void disk_page_set_dirty(Ptr); void restart_setup_page(Disk_alloc_info&, Ptr); void update_extent_pos(Disk_alloc_info&, Ptr); @@ -2679,7 +2714,7 @@ public: private: void disk_restart_undo_next(Signal*); - void disk_restart_undo_lcp(Uint32, Uint32); + void disk_restart_undo_lcp(Uint32, Uint32, Uint32 flag); void disk_restart_undo_callback(Signal* signal, Uint32, Uint32); void disk_restart_undo_alloc(Apply_undo*); void disk_restart_undo_update(Apply_undo*); diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp index 56f7fb1dd1e..069114ba287 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp @@ -68,6 +68,26 @@ operator<<(NdbOut& out, const Ptr & ptr) return out; } +#if NOT_YET_FREE_EXTENT +static +inline +bool +check_free(const Dbtup::Extent_info* extP) +{ + Uint32 res = 0; + for (Uint32 i = 1; im_free_page_count[i]; + return res; +} +#error "Code for deallocting extents when they get empty" +#error "This code is not yet complete" +#endif + +#if NOT_YET_UNDO_ALLOC_EXTENT +#error "This is needed for deallocting extents when they get empty" +#error "This code is not complete yet" +#endif + void Dbtup::dump_disk_alloc(Dbtup::Disk_alloc_info & alloc) { @@ -441,23 +461,71 @@ Dbtup::disk_page_prealloc(Signal* signal, /** * We need to alloc an extent */ +#if NOT_YET_UNDO_ALLOC_EXTENT + Uint32 logfile_group_id = fragPtr.p->m_logfile_group_id; + + err = c_lgman->alloc_log_space(logfile_group_id, + sizeof(Disk_undo::AllocExtent)>>2); + if(unlikely(err)) + { + return -err; + } +#endif + if (!c_extent_pool.seize(ext)) { + jam(); //XXX err= 2; +#if NOT_YET_UNDO_ALLOC_EXTENT + c_lgman->free_log_space(logfile_group_id, + sizeof(Disk_undo::AllocExtent)>>2); +#endif c_page_request_pool.release(req); ndbout_c("no free extent info"); return -err; } - + if ((err= tsman.alloc_extent(&ext.p->m_key)) < 0) { + jam(); +#if NOT_YET_UNDO_ALLOC_EXTENT + c_lgman->free_log_space(logfile_group_id, + sizeof(Disk_undo::AllocExtent)>>2); +#endif c_extent_pool.release(ext); c_page_request_pool.release(req); return err; } int pages= err; +#if NOT_YET_UNDO_ALLOC_EXTENT + { + /** + * Do something here + */ + { + Callback cb; + cb.m_callbackData= ext.i; + cb.m_callbackFunction = + safe_cast(&Dbtup::disk_page_alloc_extent_log_buffer_callback); + Uint32 sz= sizeof(Disk_undo::AllocExtent)>>2; + + Logfile_client lgman(this, c_lgman, logfile_group_id); + int res= lgman.get_log_buffer(signal, sz, &cb); + switch(res){ + case 0: + break; + case -1: + ndbrequire("NOT YET IMPLEMENTED" == 0); + break; + default: + execute(signal, cb, res); + } + } + } +#endif + ndbout << "allocated " << pages << " pages: " << ext.p->m_key << endl; ext.p->m_first_page_no = ext.p->m_key.m_page_no; bzero(ext.p->m_free_page_count, sizeof(ext.p->m_free_page_count)); @@ -1007,6 +1075,12 @@ Dbtup::disk_page_free(Signal *signal, extentPtr.p->m_free_space += sz; update_extent_pos(alloc, extentPtr); +#if NOT_YET_FREE_EXTENT + if (check_free(extentPtr.p) == 0) + { + ndbout_c("free: extent is free"); + } +#endif } void @@ -1104,14 +1178,56 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal, extentPtr.p->m_free_space += sz; update_extent_pos(alloc, extentPtr); +#if NOT_YET_FREE_EXTENT + if (check_free(extentPtr.p) == 0) + { + ndbout_c("abort: extent is free"); + } +#endif } +#if NOT_YET_UNDO_ALLOC_EXTENT +void +Dbtup::disk_page_alloc_extent_log_buffer_callback(Signal* signal, + Uint32 extentPtrI, + Uint32 unused) +{ + Ptr extentPtr; + c_extent_pool.getPtr(extentPtr, extentPtrI); + + Local_key key = extentPtr.p->m_key; + Tablespace_client2 tsman(signal, c_tsman, &key); + + Ptr tabPtr; + tabPtr.i= tsman.m_table_id; + ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); + + Ptr fragPtr; + getFragmentrec(fragPtr, tsman.m_fragment_id, tabPtr.p); + + Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id); + + Disk_undo::AllocExtent alloc; + alloc.m_table = tabPtr.i; + alloc.m_fragment = tsman.m_fragment_id; + alloc.m_page_no = key.m_page_no; + alloc.m_file_no = key.m_file_no; + alloc.m_type_length = (Disk_undo::UNDO_ALLOC_EXTENT<<16)|(sizeof(alloc)>> 2); + + Logfile_client::Change c[1] = {{ &alloc, sizeof(alloc) >> 2 } }; + + Uint64 lsn= lgman.add_entry(c, 1); + + tsman.update_lsn(&key, lsn); +} +#endif + Uint64 Dbtup::disk_page_undo_alloc(Page* page, const Local_key* key, Uint32 sz, Uint32 gci, Uint32 logfile_group_id) { - Logfile_client lsman(this, c_lgman, logfile_group_id); - + Logfile_client lgman(this, c_lgman, logfile_group_id); + Disk_undo::Alloc alloc; alloc.m_type_length= (Disk_undo::UNDO_ALLOC << 16) | (sizeof(alloc) >> 2); alloc.m_page_no = key->m_page_no; @@ -1119,7 +1235,7 @@ Dbtup::disk_page_undo_alloc(Page* page, const Local_key* key, Logfile_client::Change c[1] = {{ &alloc, sizeof(alloc) >> 2 } }; - Uint64 lsn= lsman.add_entry(c, 1); + Uint64 lsn= lgman.add_entry(c, 1); m_pgman.update_lsn(* key, lsn); return lsn; @@ -1130,7 +1246,7 @@ Dbtup::disk_page_undo_update(Page* page, const Local_key* key, const Uint32* src, Uint32 sz, Uint32 gci, Uint32 logfile_group_id) { - Logfile_client lsman(this, c_lgman, logfile_group_id); + Logfile_client lgman(this, c_lgman, logfile_group_id); Disk_undo::Update update; update.m_page_no = key->m_page_no; @@ -1148,7 +1264,7 @@ Dbtup::disk_page_undo_update(Page* page, const Local_key* key, ndbassert(4*(3 + sz + 1) == (sizeof(update) + 4*sz - 4)); - Uint64 lsn= lsman.add_entry(c, 3); + Uint64 lsn= lgman.add_entry(c, 3); m_pgman.update_lsn(* key, lsn); return lsn; @@ -1159,7 +1275,7 @@ Dbtup::disk_page_undo_free(Page* page, const Local_key* key, const Uint32* src, Uint32 sz, Uint32 gci, Uint32 logfile_group_id) { - Logfile_client lsman(this, c_lgman, logfile_group_id); + Logfile_client lgman(this, c_lgman, logfile_group_id); Disk_undo::Free free; free.m_page_no = key->m_page_no; @@ -1177,7 +1293,7 @@ Dbtup::disk_page_undo_free(Page* page, const Local_key* key, ndbassert(4*(3 + sz + 1) == (sizeof(free) + 4*sz - 4)); - Uint64 lsn= lsman.add_entry(c, 3); + Uint64 lsn= lgman.add_entry(c, 3); m_pgman.update_lsn(* key, lsn); return lsn; @@ -1207,7 +1323,7 @@ Dbtup::disk_restart_undo(Signal* signal, Uint64 lsn, ndbrequire(len == 3); Uint32 tableId = ptr[1] >> 16; Uint32 fragId = ptr[1] & 0xFFFF; - disk_restart_undo_lcp(tableId, fragId); + disk_restart_undo_lcp(tableId, fragId, Fragrecord::UC_LCP); disk_restart_undo_next(signal); return; } @@ -1246,10 +1362,20 @@ Dbtup::disk_restart_undo(Signal* signal, Uint64 lsn, ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); for(Uint32 i = 0; ifragrec[i] != RNIL) - disk_restart_undo_lcp(tabPtr.i, tabPtr.p->fragid[i]); + disk_restart_undo_lcp(tabPtr.i, tabPtr.p->fragid[i], + Fragrecord::UC_CREATE); disk_restart_undo_next(signal); return; } + case File_formats::Undofile::UNDO_TUP_DROP: + jam(); + case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT: + jam(); + case File_formats::Undofile::UNDO_TUP_FREE_EXTENT: + jam(); + disk_restart_undo_next(signal); + return; + case File_formats::Undofile::UNDO_END: f_undo_done = true; return; @@ -1283,7 +1409,7 @@ Dbtup::disk_restart_undo_next(Signal* signal) } void -Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId) +Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId, Uint32 flag) { Ptr tabPtr; tabPtr.i= tableId; @@ -1295,7 +1421,7 @@ Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId) getFragmentrec(fragPtr, fragId, tabPtr.p); if (!fragPtr.isNull()) { - fragPtr.p->m_undo_complete = true; + fragPtr.p->m_undo_complete |= flag; } } } @@ -1502,6 +1628,12 @@ Dbtup::disk_restart_alloc_extent(Uint32 tableId, Uint32 fragId, if (tabPtr.p->tableStatus == DEFINED) { getFragmentrec(fragPtr, fragId, tabPtr.p); + if (fragPtr.p->m_undo_complete & Fragrecord::UC_CREATE) + { + jam(); + return -1; + } + if (!fragPtr.isNull()) { Disk_alloc_info& alloc= fragPtr.p->m_disk_alloc_info; diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index f36d522005d..5b9e0d2d74f 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -3129,7 +3129,7 @@ Dbtup::nr_delete(Signal* signal, Uint32 senderData, disk_page_set_dirty(disk_page); preq.m_callback.m_callbackFunction = - safe_cast(&Dbtup::nr_delete_logbuffer_callback); + safe_cast(&Dbtup::nr_delete_log_buffer_callback); Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id); res= lgman.get_log_buffer(signal, sz, &preq.m_callback); switch(res){ @@ -3182,7 +3182,7 @@ Dbtup::nr_delete_page_callback(Signal* signal, Callback cb; cb.m_callbackData = userpointer; cb.m_callbackFunction = - safe_cast(&Dbtup::nr_delete_logbuffer_callback); + safe_cast(&Dbtup::nr_delete_log_buffer_callback); Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id); int res= lgman.get_log_buffer(signal, sz, &cb); switch(res){ @@ -3202,7 +3202,7 @@ Dbtup::nr_delete_page_callback(Signal* signal, } void -Dbtup::nr_delete_logbuffer_callback(Signal* signal, +Dbtup::nr_delete_log_buffer_callback(Signal* signal, Uint32 userpointer, Uint32 unused) { diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index fff557583be..e0f0fd84ee3 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -164,7 +164,7 @@ void Dbtup::execCONTINUEB(Signal* signal) break; case ZREL_FRAG: ljam(); - releaseFragment(signal, dataPtr); + releaseFragment(signal, dataPtr, signal->theData[2]); break; case ZREPORT_MEMORY_USAGE:{ ljam(); @@ -223,7 +223,7 @@ void Dbtup::execCONTINUEB(Signal* signal) fragPtr.i= signal->theData[2]; ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord); - drop_fragment_free_exent(signal, tabPtr, fragPtr, signal->theData[3]); + drop_fragment_free_extent(signal, tabPtr, fragPtr, signal->theData[3]); return; } case ZUNMAP_PAGES: diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp index 8db8f423817..f6f7cef2a5e 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp @@ -309,6 +309,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) if(lastAttr) { + jam(); /** * Init Disk_alloc_info */ @@ -320,6 +321,11 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) ndbrequire(tsman.get_tablespace_info(&rep) == 0); regFragPtr.p->m_logfile_group_id= rep.tablespace.logfile_group_id; } + else + { + jam(); + regFragPtr.p->m_logfile_group_id = RNIL; + } new (®FragPtr.p->m_disk_alloc_info) Disk_alloc_info(regTabPtr.p, rep.tablespace.extent_size); releaseFragoperrec(fragOperPtr); @@ -564,7 +570,12 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) regFragPtr.p->m_tablespace_id); ndbrequire(tsman.get_tablespace_info(&rep) == 0); regFragPtr.p->m_logfile_group_id= rep.tablespace.logfile_group_id; - } + } + else + { + jam(); + regFragPtr.p->m_logfile_group_id = RNIL; + } new (®FragPtr.p->m_disk_alloc_info) Disk_alloc_info(regTabPtr.p, rep.tablespace.extent_size); @@ -597,7 +608,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) ndbrequire("NOT YET IMPLEMENTED" == 0); break; } - execute(signal, cb, 0); + execute(signal, cb, regFragPtr.p->m_logfile_group_id); return; } } @@ -874,7 +885,8 @@ Dbtup::execDROP_TAB_REQ(Signal* signal) signal->theData[0]= ZREL_FRAG; signal->theData[1]= tabPtr.i; - sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB); + signal->theData[2]= RNIL; + sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB); } void Dbtup::releaseTabDescr(Tablerec* const regTabPtr) @@ -902,7 +914,8 @@ void Dbtup::releaseTabDescr(Tablerec* const regTabPtr) } } -void Dbtup::releaseFragment(Signal* signal, Uint32 tableId) +void Dbtup::releaseFragment(Signal* signal, Uint32 tableId, + Uint32 logfile_group_id) { TablerecPtr tabPtr; tabPtr.i= tableId; @@ -929,16 +942,35 @@ void Dbtup::releaseFragment(Signal* signal, Uint32 tableId) sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB); return; } + +#if NOT_YET_UNDO_DROP_TABLE +#error "This code is complete, but I prefer not to enable it until I need it" + if (logfile_group_id != RNIL) + { + Callback cb; + cb.m_callbackData= tabPtr.i; + cb.m_callbackFunction = + safe_cast(&Dbtup::drop_table_log_buffer_callback); + Uint32 sz= sizeof(Disk_undo::Drop) >> 2; + int r0 = c_lgman->alloc_log_space(logfile_group_id, sz); + + Logfile_client lgman(this, c_lgman, logfile_group_id); + int res= lgman.get_log_buffer(signal, sz, &cb); + switch(res){ + case 0: + ljam(); + return; + case -1: + ndbrequire("NOT YET IMPLEMENTED" == 0); + break; + default: + execute(signal, cb, logfile_group_id); + return; + } + } +#endif - DropTabConf * const dropConf= (DropTabConf *)signal->getDataPtrSend(); - dropConf->senderRef= reference(); - dropConf->senderData= tabPtr.p->m_dropTable.tabUserPtr; - dropConf->tableId= tabPtr.i; - sendSignal(tabPtr.p->m_dropTable.tabUserRef, GSN_DROP_TAB_CONF, - signal, DropTabConf::SignalLength, JBB); - - releaseTabDescr(tabPtr.p); - initTab(tabPtr.p); + drop_table_logsync_callback(signal, tabPtr.i, RNIL); } void @@ -965,7 +997,7 @@ Dbtup::drop_fragment_unmap_pages(Signal *signal, alloc_info.m_curr_extent_info_ptr_i= RNIL; } - drop_fragment_free_exent(signal, tabPtr, fragPtr, 0); + drop_fragment_free_extent(signal, tabPtr, fragPtr, 0); return; } @@ -998,7 +1030,7 @@ Dbtup::drop_fragment_unmap_pages(Signal *signal, } return; } - drop_fragment_free_exent(signal, tabPtr, fragPtr, 0); + drop_fragment_free_extent(signal, tabPtr, fragPtr, 0); } void @@ -1031,10 +1063,10 @@ Dbtup::drop_fragment_unmap_page_callback(Signal* signal, } void -Dbtup::drop_fragment_free_exent(Signal *signal, - TablerecPtr tabPtr, - FragrecordPtr fragPtr, - Uint32 pos) +Dbtup::drop_fragment_free_extent(Signal *signal, + TablerecPtr tabPtr, + FragrecordPtr fragPtr, + Uint32 pos) { if (tabPtr.p->m_no_of_disk_attributes) { @@ -1044,25 +1076,32 @@ Dbtup::drop_fragment_free_exent(Signal *signal, if(!alloc_info.m_free_extents[pos].isEmpty()) { jam(); - Local_extent_info_list - list(c_extent_pool, alloc_info.m_free_extents[pos]); - Ptr ext_ptr; - list.first(ext_ptr); + Callback cb; + cb.m_callbackData= fragPtr.i; + cb.m_callbackFunction = + safe_cast(&Dbtup::drop_fragment_free_extent_log_buffer_callback); +#if NOT_YET_UNDO_FREE_EXTENT + Uint32 sz= sizeof(Disk_undo::FreeExtent) >> 2; + int r0 = c_lgman->alloc_log_space(fragPtr.p->m_logfile_group_id, sz); - Tablespace_client tsman(signal, c_tsman, tabPtr.i, - fragPtr.p->fragmentId, - fragPtr.p->m_tablespace_id); + Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id); - tsman.free_extent(&ext_ptr.p->m_key); - c_extent_hash.remove(ext_ptr); - list.release(ext_ptr); - - signal->theData[0] = ZFREE_EXTENT; - signal->theData[1] = tabPtr.i; - signal->theData[2] = fragPtr.i; - signal->theData[3] = pos; - sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB); + int res= lgman.get_log_buffer(signal, sz, &cb); + switch(res){ + case 0: + ljam(); + return; + case -1: + ndbrequire("NOT YET IMPLEMENTED" == 0); + break; + default: + execute(signal, cb, fragPtr.p->m_logfile_group_id); + return; + } +#else + execute(signal, cb, fragPtr.p->m_logfile_group_id); return; +#endif } } @@ -1081,6 +1120,123 @@ Dbtup::drop_fragment_free_exent(Signal *signal, sendSignal(reference(), GSN_CONTINUEB, signal, 3, JBB); } +void +Dbtup::drop_table_log_buffer_callback(Signal* signal, Uint32 tablePtrI, + Uint32 logfile_group_id) +{ + TablerecPtr tabPtr; + tabPtr.i = tablePtrI; + ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); + + ndbrequire(tabPtr.p->m_no_of_disk_attributes); + + Disk_undo::Drop drop; + drop.m_table = tabPtr.i; + drop.m_type_length = + (Disk_undo::UNDO_DROP << 16) | (sizeof(drop) >> 2); + Logfile_client lgman(this, c_lgman, logfile_group_id); + + Logfile_client::Change c[1] = {{ &drop, sizeof(drop) >> 2 } }; + Uint64 lsn = lgman.add_entry(c, 1); + + Logfile_client::Request req; + req.m_callback.m_callbackData= tablePtrI; + req.m_callback.m_callbackFunction = + safe_cast(&Dbtup::drop_table_logsync_callback); + + int ret = lgman.sync_lsn(signal, lsn, &req, 0); + switch(ret){ + case 0: + return; + default: + ndbout_c("ret: %d", ret); + ndbrequire(false); + } +} + +void +Dbtup::drop_table_logsync_callback(Signal* signal, + Uint32 tabPtrI, + Uint32 logfile_group_id) +{ + TablerecPtr tabPtr; + tabPtr.i = tabPtrI; + ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); + + DropTabConf * const dropConf= (DropTabConf *)signal->getDataPtrSend(); + dropConf->senderRef= reference(); + dropConf->senderData= tabPtr.p->m_dropTable.tabUserPtr; + dropConf->tableId= tabPtr.i; + sendSignal(tabPtr.p->m_dropTable.tabUserRef, GSN_DROP_TAB_CONF, + signal, DropTabConf::SignalLength, JBB); + + releaseTabDescr(tabPtr.p); + initTab(tabPtr.p); +} + +void +Dbtup::drop_fragment_free_extent_log_buffer_callback(Signal* signal, + Uint32 fragPtrI, + Uint32 unused) +{ + FragrecordPtr fragPtr; + fragPtr.i = fragPtrI; + ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord); + + TablerecPtr tabPtr; + tabPtr.i = fragPtr.p->fragTableId; + ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec); + + ndbrequire(tabPtr.p->m_no_of_disk_attributes); + Disk_alloc_info& alloc_info= fragPtr.p->m_disk_alloc_info; + + for(Uint32 pos = 0; pos ext_ptr; + list.first(ext_ptr); + +#if NOT_YET_UNDO_FREE_EXTENT +#error "This code is complete" +#error "but not needed until we do dealloc of empty extents" + Disk_undo::FreeExtent free; + free.m_table = tabPtr.i; + free.m_fragment = fragPtr.p->fragmentId; + free.m_file_no = ext_ptr.p->m_key.m_file_no; + free.m_page_no = ext_ptr.p->m_key.m_page_no; + free.m_type_length = + (Disk_undo::UNDO_FREE_EXTENT << 16) | (sizeof(free) >> 2); + Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id); + + Logfile_client::Change c[1] = {{ &free, sizeof(free) >> 2 } }; + Uint64 lsn = lgman.add_entry(c, 1); +#else + Uint64 lsn = 0; +#endif + + Tablespace_client tsman(signal, c_tsman, tabPtr.i, + fragPtr.p->fragmentId, + fragPtr.p->m_tablespace_id); + + tsman.free_extent(&ext_ptr.p->m_key, lsn); + c_extent_hash.remove(ext_ptr); + list.release(ext_ptr); + + signal->theData[0] = ZFREE_EXTENT; + signal->theData[1] = tabPtr.i; + signal->theData[2] = fragPtr.i; + signal->theData[3] = pos; + sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB); + return; + } + } + ndbrequire(false); +} + void Dbtup::drop_fragment_free_var_pages(Signal* signal) { @@ -1112,7 +1268,7 @@ Dbtup::drop_fragment_free_var_pages(Signal* signal) sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB); return; } - + Uint32 logfile_group_id = fragPtr.p->m_logfile_group_id ; releaseFragPages(fragPtr.p); Uint32 i; for(i= 0; itheData[0]= ZREL_FRAG; signal->theData[1]= tabPtr.i; - sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB); + signal->theData[2]= logfile_group_id; + sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB); return; } diff --git a/storage/ndb/src/kernel/blocks/diskpage.hpp b/storage/ndb/src/kernel/blocks/diskpage.hpp index 044597be1cf..c75f2a0c070 100644 --- a/storage/ndb/src/kernel/blocks/diskpage.hpp +++ b/storage/ndb/src/kernel/blocks/diskpage.hpp @@ -154,7 +154,10 @@ struct File_formats ,UNDO_TUP_UPDATE = 4 ,UNDO_TUP_FREE = 5 ,UNDO_TUP_CREATE = 6 - + ,UNDO_TUP_DROP = 7 + ,UNDO_TUP_ALLOC_EXTENT = 8 + ,UNDO_TUP_FREE_EXTENT = 9 + ,UNDO_END = 0x7FFF ,UNDO_NEXT_LSN = 0x8000 }; diff --git a/storage/ndb/src/kernel/blocks/lgman.cpp b/storage/ndb/src/kernel/blocks/lgman.cpp index d4cc0cb89e8..a71b817944f 100644 --- a/storage/ndb/src/kernel/blocks/lgman.cpp +++ b/storage/ndb/src/kernel/blocks/lgman.cpp @@ -1160,14 +1160,15 @@ Lgman::process_log_sync_waiters(Signal* signal, Ptr ptr) bool removed= false; Ptr waiter; list.first(waiter); + Uint32 logfile_group_id = ptr.p->m_logfile_group_id; if(waiter.p->m_sync_lsn <= ptr.p->m_last_synced_lsn) { removed= true; Uint32 block = waiter.p->m_block; SimulatedBlock* b = globalData.getBlock(block); - b->execute(signal, waiter.p->m_callback, 0); - + b->execute(signal, waiter.p->m_callback, logfile_group_id); + list.releaseFirst(waiter); } @@ -1522,12 +1523,13 @@ Lgman::process_log_buffer_waiters(Signal* signal, Ptr ptr) bool removed= false; Ptr waiter; list.first(waiter); + Uint32 logfile_group_id = ptr.p->m_logfile_group_id; if(waiter.p->m_size + 2*File_formats::UNDO_PAGE_WORDS < free_buffer) { removed= true; Uint32 block = waiter.p->m_block; SimulatedBlock* b = globalData.getBlock(block); - b->execute(signal, waiter.p->m_callback, 0); + b->execute(signal, waiter.p->m_callback, logfile_group_id); list.releaseFirst(waiter); } @@ -2699,6 +2701,9 @@ Lgman::execute_undo_record(Signal* signal) case File_formats::Undofile::UNDO_TUP_UPDATE: case File_formats::Undofile::UNDO_TUP_FREE: case File_formats::Undofile::UNDO_TUP_CREATE: + case File_formats::Undofile::UNDO_TUP_DROP: + case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT: + case File_formats::Undofile::UNDO_TUP_FREE_EXTENT: tup->disk_restart_undo(signal, lsn, mask, ptr - len + 1, len); return; default: diff --git a/storage/ndb/src/kernel/blocks/print_file.cpp b/storage/ndb/src/kernel/blocks/print_file.cpp index 14b83cccaee..696658ef8de 100644 --- a/storage/ndb/src/kernel/blocks/print_file.cpp +++ b/storage/ndb/src/kernel/blocks/print_file.cpp @@ -304,6 +304,8 @@ print_undo_page(int count, void* ptr, Uint32 sz){ case File_formats::Undofile::UNDO_LCP: printf("[ %lld LCP %d tab: %d frag: %d ]", lsn, src[0], src[1] >> 16, src[1] & 0xFFFF); + if(g_verbosity <= 3) + printf("\n"); break; case File_formats::Undofile::UNDO_TUP_ALLOC: if(g_verbosity > 3) @@ -340,6 +342,48 @@ print_undo_page(int count, void* ptr, Uint32 sz){ req->m_gci); } break; + case File_formats::Undofile::UNDO_TUP_CREATE: + { + Dbtup::Disk_undo::Create *req = (Dbtup::Disk_undo::Create*)src; + printf("[ %lld Create %d ]", lsn, req->m_table); + if(g_verbosity <= 3) + printf("\n"); + break; + } + case File_formats::Undofile::UNDO_TUP_DROP: + { + Dbtup::Disk_undo::Drop *req = (Dbtup::Disk_undo::Drop*)src; + printf("[ %lld Drop %d ]", lsn, req->m_table); + if(g_verbosity <= 3) + printf("\n"); + break; + } + case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT: + { + Dbtup::Disk_undo::AllocExtent *req = (Dbtup::Disk_undo::AllocExtent*)src; + printf("[ %lld AllocExtent tab: %d frag: %d file: %d page: %d ]", + lsn, + req->m_table, + req->m_fragment, + req->m_file_no, + req->m_page_no); + if(g_verbosity <= 3) + printf("\n"); + break; + } + case File_formats::Undofile::UNDO_TUP_FREE_EXTENT: + { + Dbtup::Disk_undo::FreeExtent *req = (Dbtup::Disk_undo::FreeExtent*)src; + printf("[ %lld FreeExtent tab: %d frag: %d file: %d page: %d ]", + lsn, + req->m_table, + req->m_fragment, + req->m_file_no, + req->m_page_no); + if(g_verbosity <= 3) + printf("\n"); + break; + } default: ndbout_c("[ Unknown type %d len: %d, pos: %d ]", type, len, pos); if(!(len && type)) @@ -361,11 +405,11 @@ print_undo_page(int count, void* ptr, Uint32 sz){ } } } - + if(count == g_uf_zero.m_undo_pages + 1) { } - + return 0; } diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp index 89725ca309e..3c1ddac714c 100644 --- a/storage/ndb/src/kernel/blocks/tsman.cpp +++ b/storage/ndb/src/kernel/blocks/tsman.cpp @@ -79,12 +79,14 @@ Tsman::Tsman(Block_context& ctx, addRecSignal(GSN_START_RECREQ, &Tsman::execSTART_RECREQ); + addRecSignal(GSN_LCP_FRAG_ORD, &Tsman::execLCP_FRAG_ORD); addRecSignal(GSN_END_LCP_REQ, &Tsman::execEND_LCP_REQ); addRecSignal(GSN_GET_TABINFOREQ, &Tsman::execGET_TABINFOREQ); m_tablespace_hash.setSize(10); m_file_hash.setSize(10); + m_lcp_ongoing = false; } Tsman::~Tsman() @@ -1101,6 +1103,7 @@ Tsman::load_extent_page_callback(Signal* signal, ptr.p->m_online.m_lcp_free_extent_tail = RNIL; ptr.p->m_online.m_data_pages = data_pages; ptr.p->m_online.m_used_extent_cnt = 0; + ptr.p->m_online.m_extent_headers_per_extent_page = per_page; Ptr ts_ptr; m_tablespace_pool.getPtr(ts_ptr, ptr.p->m_tablespace_ptr_i); @@ -1182,9 +1185,8 @@ Tsman::scan_extent_headers(Signal* signal, Ptr ptr) m_tablespace_pool.getPtr(lg_ptr, ptr.p->m_tablespace_ptr_i); Uint32 firstFree= RNIL; - Uint32 size = lg_ptr.p->m_extent_size; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; + Uint32 size = ptr.p->m_extent_size; + Uint32 per_page = ptr.p->m_online.m_extent_headers_per_extent_page; Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; Uint32 pages= ptr.p->m_online.m_offset_data_pages - 1; Uint32 datapages= ptr.p->m_online.m_data_pages; @@ -1410,23 +1412,21 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal) AllocExtentReq::ErrorCode err; ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id)); - Uint32 size = ts_ptr.p->m_extent_size; Local_datafile_list tmp(m_file_pool, ts_ptr.p->m_free_files); if (tmp.first(file_ptr)) { - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - + Uint32 size = file_ptr.p->m_extent_size; Uint32 extent = file_ptr.p->m_online.m_first_free_extent; Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; + Uint32 eh_words = File_formats::Datafile::extent_header_words(size); + Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; Uint32 page_no = extent / per_page; Uint32 extent_no = extent % per_page; Page_cache_client::Request preq; preq.m_page.m_page_no = page_no; preq.m_page.m_file_no = file_ptr.p->m_file_no; - preq.m_page.m_page_idx = extent; /** * Handling of unmapped extent header pages is not implemented @@ -1501,28 +1501,21 @@ void Tsman::execFREE_EXTENT_REQ(Signal* signal) { jamEntry(); - Ptr ts_ptr; Ptr file_ptr; FreeExtentReq req = *(FreeExtentReq*)signal->getDataPtr(); FreeExtentReq::ErrorCode err = (FreeExtentReq::ErrorCode)0; - ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id)); Datafile file_key; file_key.m_file_no = req.request.key.m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - Uint32 size = ts_ptr.p->m_extent_size; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 extent = (req.request.key.m_page_no - data_off) / size + per_page; - - - Uint32 page_no = extent / per_page; - Uint32 extent_no = extent % per_page; + struct req val = lookup_extent(req.request.key.m_page_no, file_ptr.p); + Uint32 extent = + (req.request.key.m_page_no - val.m_extent_pages) / val.m_extent_size + + file_ptr.p->m_online.m_extent_headers_per_extent_page; Page_cache_client::Request preq; - preq.m_page.m_page_no = page_no; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = req.request.key.m_file_no; ndbout << "Free extent: " << req.request.key << endl; @@ -1539,16 +1532,38 @@ Tsman::execFREE_EXTENT_REQ(Signal* signal) File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; File_formats::Datafile::Extent_header* header = - page->get_header(extent_no, size); + page->get_header(val.m_extent_no, val.m_extent_size); ndbrequire(header->m_table == req.request.table_id); header->m_table = RNIL; - header->m_next_free_extent= file_ptr.p->m_online.m_lcp_free_extent_head; - if(file_ptr.p->m_online.m_lcp_free_extent_head == RNIL) - file_ptr.p->m_online.m_lcp_free_extent_tail= extent; - file_ptr.p->m_online.m_lcp_free_extent_head= extent; file_ptr.p->m_online.m_used_extent_cnt--; + if (m_lcp_ongoing) + { + jam(); + header->m_next_free_extent= file_ptr.p->m_online.m_lcp_free_extent_head; + if(file_ptr.p->m_online.m_lcp_free_extent_head == RNIL) + file_ptr.p->m_online.m_lcp_free_extent_tail= extent; + file_ptr.p->m_online.m_lcp_free_extent_head= extent; + } + else + { + jam(); + header->m_next_free_extent = file_ptr.p->m_online.m_first_free_extent; + if (file_ptr.p->m_online.m_first_free_extent == RNIL) + { + /** + * Move from full to free + */ + Ptr ptr; + m_tablespace_pool.getPtr(ptr, file_ptr.p->m_tablespace_ptr_i); + Local_datafile_list free(m_file_pool, ptr.p->m_free_files); + Local_datafile_list full(m_file_pool, ptr.p->m_full_files); + full.remove(file_ptr); + free.add(file_ptr); + } + file_ptr.p->m_online.m_first_free_extent = extent; + } } else { @@ -1583,18 +1598,10 @@ Tsman::update_page_free_bits(Signal* signal, file_key.m_file_no = key->m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - Uint32 size = file_ptr.p->m_extent_size; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; - - Uint32 extent = (key->m_page_no - data_off) / size + per_page; - Uint32 page_no = extent / per_page; - Uint32 extent_no = extent % per_page; + struct req val = lookup_extent(key->m_page_no, file_ptr.p); Page_cache_client::Request preq; - preq.m_page.m_page_no = page_no; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = key->m_file_no; /** @@ -1609,12 +1616,12 @@ Tsman::update_page_free_bits(Signal* signal, File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; File_formats::Datafile::Extent_header* header = - page->get_header(extent_no, size); + page->get_header(val.m_extent_no, val.m_extent_size); ndbrequire(header->m_table != RNIL); - Uint32 page_no_in_extent = (key->m_page_no - data_off) % size; - + Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val); + /** * Toggle word */ @@ -1637,26 +1644,15 @@ Tsman::get_page_free_bits(Signal* signal, Local_key *key, { jamEntry(); - /** - * XXX make into subroutine - */ Ptr file_ptr; Datafile file_key; file_key.m_file_no = key->m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - - Uint32 size = file_ptr.p->m_extent_size; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; - Uint32 extent = (key->m_page_no - data_off) / size + per_page; - Uint32 page_no = extent / per_page; - Uint32 extent_no = extent % per_page; + struct req val = lookup_extent(key->m_page_no, file_ptr.p); Page_cache_client::Request preq; - preq.m_page.m_page_no = page_no; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = key->m_file_no; /** @@ -1671,11 +1667,11 @@ Tsman::get_page_free_bits(Signal* signal, Local_key *key, File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; File_formats::Datafile::Extent_header* header = - page->get_header(extent_no, size); + page->get_header(val.m_extent_no, val.m_extent_size); ndbrequire(header->m_table != RNIL); - Uint32 page_no_in_extent = (key->m_page_no - data_off) % size; + Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val); Uint32 bits = header->get_free_bits(page_no_in_extent); *uncommitted = (bits & UNCOMMITTED_MASK) >> UNCOMMITTED_SHIFT; *committed = (bits & COMMITTED_MASK); @@ -1700,19 +1696,11 @@ Tsman::unmap_page(Signal* signal, Local_key *key, Uint32 uncommitted_bits) Datafile file_key; file_key.m_file_no = key->m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - - Uint32 size = file_ptr.p->m_extent_size; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; - - Uint32 extent = (key->m_page_no - data_off) / size + per_page; - Uint32 page_no = extent / per_page; - Uint32 extent_no = extent % per_page; + + struct req val = lookup_extent(key->m_page_no, file_ptr.p); Page_cache_client::Request preq; - preq.m_page.m_page_no = page_no; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = key->m_file_no; /** @@ -1727,12 +1715,12 @@ Tsman::unmap_page(Signal* signal, Local_key *key, Uint32 uncommitted_bits) File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; File_formats::Datafile::Extent_header* header = - page->get_header(extent_no, size); + page->get_header(val.m_extent_no, val.m_extent_size); ndbrequire(header->m_table != RNIL); - Uint32 page_no_in_extent = (key->m_page_no - data_off) % size; - + Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val); + /** * Toggle word */ @@ -1767,18 +1755,10 @@ Tsman::restart_undo_page_free_bits(Signal* signal, file_key.m_file_no = key->m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - Uint32 size = file_ptr.p->m_extent_size; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; - - Uint32 extent = (key->m_page_no - data_off) / size + per_page; - Uint32 page_no = extent / per_page; - Uint32 extent_no = extent % per_page; - + struct req val = lookup_extent(key->m_page_no, file_ptr.p); + Page_cache_client::Request preq; - preq.m_page.m_page_no = page_no; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = key->m_file_no; /** @@ -1793,7 +1773,7 @@ Tsman::restart_undo_page_free_bits(Signal* signal, File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; File_formats::Datafile::Extent_header* header = - page->get_header(extent_no, size); + page->get_header(val.m_extent_no, val.m_extent_size); Uint64 lsn = 0; lsn += page->m_page_header.m_page_lsn_hi; lsn <<= 32; @@ -1816,7 +1796,7 @@ Tsman::restart_undo_page_free_bits(Signal* signal, return 0; } - Uint32 page_no_in_extent = (key->m_page_no - data_off) % size; + Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val); Uint32 src = header->get_free_bits(page_no_in_extent); ndbrequire(header->m_table == tableId); @@ -1862,17 +1842,11 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal) Datafile file_key; file_key.m_file_no = req.key.m_file_no; ndbrequire(m_file_hash.find(file_ptr, file_key)); - - Uint32 size = file_ptr.p->m_extent_size; - Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages; - Uint32 eh_words = File_formats::Datafile::extent_header_words(size); - Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words; - - Uint32 extent = (req.key.m_page_no - data_off) / size; - Uint32 extent_no = extent % per_page; + + struct req val = lookup_extent(req.key.m_page_no, file_ptr.p); Page_cache_client::Request preq; - preq.m_page.m_page_no = 1 /* zero */ + extent / per_page; + preq.m_page.m_page_no = val.m_extent_page_no; preq.m_page.m_file_no = req.key.m_file_no; Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE; @@ -1891,11 +1865,11 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal) File_formats::Datafile::Extent_page* page = (File_formats::Datafile::Extent_page*)ptr_p; - header= page->get_header(extent_no, size); + header= page->get_header(val.m_extent_no, val.m_extent_size); ndbrequire(header->m_table == req.request.table_id); - Uint32 page_no_in_extent = (req.key.m_page_no - data_off) % size; + Uint32 page_no_in_extent = calc_page_no_in_extent(req.key.m_page_no, &val); Uint32 word = header->get_free_word_offset(page_no_in_extent); Uint32 shift = SZ * (page_no_in_extent & 7); @@ -1912,7 +1886,7 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal) * Search */ Uint32 *src= header->m_page_bitmask + word; - for(page_no= page_no_in_extent; page_no> shift) & ((1 << SZ) - 1); if((src_bits & UNCOMMITTED_MASK) <= reqbits) @@ -1955,15 +1929,26 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal) found: header->update_free_bits(page_no, src_bits | UNCOMMITTED_MASK); rep->bits= (src_bits & UNCOMMITTED_MASK) >> UNCOMMITTED_SHIFT; - rep->key.m_page_no= data_off + extent * size + page_no; + rep->key.m_page_no= + val.m_extent_pages + val.m_extent_no * val.m_extent_size + page_no; rep->reply.errorCode= 0; return; } +void +Tsman::execLCP_FRAG_ORD(Signal* signal) +{ + jamEntry(); + ndbrequire(!m_lcp_ongoing); + m_lcp_ongoing = true; +} + void Tsman::execEND_LCP_REQ(Signal* signal) { jamEntry(); + ndbrequire(m_lcp_ongoing); + m_lcp_ongoing = false; /** * Move extents from "lcp" free list to real free list diff --git a/storage/ndb/src/kernel/blocks/tsman.hpp b/storage/ndb/src/kernel/blocks/tsman.hpp index 7c92dfcb068..018d648de07 100644 --- a/storage/ndb/src/kernel/blocks/tsman.hpp +++ b/storage/ndb/src/kernel/blocks/tsman.hpp @@ -63,6 +63,7 @@ protected: void execALLOC_PAGE_REQ(Signal* signal); + void execLCP_FRAG_ORD(Signal*); void execEND_LCP_REQ(Signal*); void end_lcp(Signal*, Uint32 tablespace, Uint32 list, Uint32 file); @@ -108,6 +109,7 @@ public: Uint32 m_offset_data_pages; // 1(zero) + extent header pages Uint32 m_data_pages; Uint32 m_used_extent_cnt; + Uint32 m_extent_headers_per_extent_page; } m_online; struct { Uint32 m_senderData; @@ -196,6 +198,7 @@ private: Datafile_pool m_file_pool; Tablespace_pool m_tablespace_pool; + bool m_lcp_ongoing; Datafile_hash m_file_hash; Tablespace_list m_tablespace_list; Tablespace_hash m_tablespace_hash; @@ -226,15 +229,52 @@ private: void release_extent_pages(Signal* signal, Ptr ptr); void release_extent_pages_callback(Signal*, Uint32, Uint32); + + struct req + { + Uint32 m_extent_pages; + Uint32 m_extent_size; + Uint32 m_extent_no; // on extent page + Uint32 m_extent_page_no; + }; + + struct req lookup_extent(Uint32 page_no, const Datafile*) const; + Uint32 calc_page_no_in_extent(Uint32 page_no, const struct req* val) const; }; +inline +Tsman::req +Tsman::lookup_extent(Uint32 page_no, const Datafile * filePtrP) const +{ + struct req val; + val.m_extent_size = filePtrP->m_extent_size; + val.m_extent_pages = filePtrP->m_online.m_offset_data_pages; + Uint32 per_page = filePtrP->m_online.m_extent_headers_per_extent_page; + + Uint32 extent = + (page_no - val.m_extent_pages) / val.m_extent_size + per_page; + + val.m_extent_page_no = extent / per_page; + val.m_extent_no = extent % per_page; + return val; +} + +inline +Uint32 +Tsman::calc_page_no_in_extent(Uint32 page_no, const Tsman::req* val) const +{ + return (page_no - val->m_extent_pages) % val->m_extent_size; +} + class Tablespace_client { +public: Tsman * m_tsman; Signal* m_signal; Uint32 m_table_id; Uint32 m_fragment_id; Uint32 m_tablespace_id; + public: Tablespace_client(Signal* signal, Tsman* tsman, Uint32 table, Uint32 fragment, Uint32 tablespaceId) { @@ -244,6 +284,8 @@ public: m_fragment_id= fragment; m_tablespace_id= tablespaceId; } + + Tablespace_client(Signal* signal, Tsman* tsman, Local_key* key); /** * Return >0 if success, no of pages in extent, sets key @@ -274,7 +316,7 @@ public: /** * Free extent */ - int free_extent(Local_key* key); + int free_extent(Local_key* key, Uint64 lsn); /** * Update page free bits @@ -307,6 +349,11 @@ public: * <0 - on error */ int get_tablespace_info(CreateFilegroupImplReq* rep); + + /** + * Update lsn of page corresponing to key + */ + int update_lsn(Local_key* key, Uint64 lsn); }; #include @@ -351,12 +398,14 @@ Tablespace_client::alloc_page_from_extent(Local_key* key, Uint32 bits) inline int -Tablespace_client::free_extent(Local_key* key) +Tablespace_client::free_extent(Local_key* key, Uint64 lsn) { FreeExtentReq* req = (FreeExtentReq*)m_signal->theData; req->request.key = *key; req->request.table_id = m_table_id; req->request.tablespace_id = m_tablespace_id; + req->request.lsn_hi = (Uint32)(lsn >> 32); + req->request.lsn_lo = (Uint32)(lsn & 0xFFFFFFFF); m_tsman->execFREE_EXTENT_REQ(m_signal); if(req->reply.errorCode == 0){ @@ -407,5 +456,4 @@ Tablespace_client::restart_undo_page_free_bits(Local_key* key, page_lsn); } - #endif From 93fda180d1e5aa42f48fced454dabaf73e8fb3e1 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 7 Dec 2006 15:49:59 +0100 Subject: [PATCH 07/40] Bug#24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld: Added test case --- mysql-test/r/ndb_index_unique.result | 15 +++++++++++++++ mysql-test/t/ndb_index_unique.test | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9fb6f89aa2..3bc41e8a197 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -133,6 +133,21 @@ a b c 6 7 2 7 8 3 8 2 3 +create unique index bi using hash on t2(b); +insert into t2 values(9, 3, 1); +ERROR 23000: Duplicate entry '' for key 0 +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; +a b c +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +8 2 3 +9 3 1 drop table t2; CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 458f6a165f8..2bf4a763313 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -83,6 +83,14 @@ delete from t2 where a = 1; insert into t2 values(8, 2, 3); select * from t2 order by a; +# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld +create unique index bi using hash on t2(b); +-- error 1062 +insert into t2 values(9, 3, 1); +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; + drop table t2; -- error 1121 From 6b4b4029778d29af9850118911d4b53c81030ec5 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 7 Dec 2006 16:27:38 +0100 Subject: [PATCH 08/40] Bug#24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld: Re-generated test result --- mysql-test/r/ndb_index_unique.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index d83c60e6a8d..cc63ce69760 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -139,7 +139,7 @@ a b c 8 2 3 create unique index bi using hash on t2(b); insert into t2 values(9, 3, 1); -ERROR 23000: Duplicate entry '' for key 0 +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' alter table t2 drop index bi; insert into t2 values(9, 3, 1); select * from t2 order by a; From 79542f05842bac5af0179fb84a25027464216506 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 7 Dec 2006 16:30:30 +0100 Subject: [PATCH 09/40] ps_7ndb problem now fixed --- mysql-test/t/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index e48108af9ce..d1acb34da61 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -20,7 +20,6 @@ ndb_restore_partition : Problem with cluster/def/schema table that is in std_ rpl_ndb_sync : Problem with cluster/def/schema table that is in std_data/ndb_backup51; Pekka will schdule this to someone partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table -ps_7ndb : BUG#18950 2006-02-16 jmiller create table like does not obtain LOCK_open rpl_ndb_2innodb : BUG#19227 2006-04-20 pekka pk delete apparently not replicated rpl_ndb_2myisam : BUG#19227 Seems to pass currently rpl_ndb_dd_partitions : BUG#19259 2006-04-21 rpl_ndb_dd_partitions fails on s/AMD From a460d5f288062bd671d5fd3575ee42e0592df89e Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 8 Dec 2006 10:24:48 +0100 Subject: [PATCH 10/40] ndb - bug#21948 Fix bug in previous changeset...causing SR problems with disk --- .../src/kernel/blocks/dbtup/DbtupCommit.cpp | 21 ++++++++++++++++--- storage/ndb/src/kernel/blocks/tsman.cpp | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index 0c69919d39a..df8a035c442 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -176,8 +176,11 @@ Dbtup::dealloc_tuple(Signal* signal, { Local_key disk; memcpy(&disk, ptr->get_disk_ref_ptr(regTabPtr), sizeof(disk)); + PagePtr tmpptr; + tmpptr.i = m_pgman.m_ptr.i; + tmpptr.p = reinterpret_cast(m_pgman.m_ptr.p); disk_page_free(signal, regTabPtr, regFragPtr, - &disk, *(PagePtr*)&m_pgman.m_ptr, gci); + &disk, tmpptr, gci); } if (! (bits & Tuple_header::LCP_SKIP) && lcpScan_ptr_i != RNIL) @@ -356,7 +359,12 @@ Dbtup::disk_page_commit_callback(Signal* signal, regOperPtr.p->m_commit_disk_callback_page= page_id; m_global_page_pool.getPtr(m_pgman.m_ptr, page_id); - disk_page_set_dirty(*(Ptr*)&m_pgman.m_ptr); + { + PagePtr tmp; + tmp.i = m_pgman.m_ptr.i; + tmp.p = reinterpret_cast(m_pgman.m_ptr.p); + disk_page_set_dirty(tmp); + } execTUP_COMMITREQ(signal); if(signal->theData[0] == 0) @@ -543,7 +551,14 @@ void Dbtup::execTUP_COMMITREQ(Signal* signal) break; } get_page = true; - disk_page_set_dirty(*(Ptr*)&m_pgman.m_ptr); + + { + PagePtr tmpptr; + tmpptr.i = m_pgman.m_ptr.i; + tmpptr.p = reinterpret_cast(m_pgman.m_ptr.p); + disk_page_set_dirty(tmpptr); + } + regOperPtr.p->m_commit_disk_callback_page= res; regOperPtr.p->op_struct.m_load_diskpage_on_commit= 0; } diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp index 3c1ddac714c..48a8d470ccc 100644 --- a/storage/ndb/src/kernel/blocks/tsman.cpp +++ b/storage/ndb/src/kernel/blocks/tsman.cpp @@ -1470,6 +1470,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal) */ ndbassert(extent >= per_page); preq.m_page.m_page_no = data_off + size * (extent - /* zero */ per_page); + preq.m_page.m_page_idx = extent; // extent_no AllocExtentReq* rep = (AllocExtentReq*)signal->getDataPtr(); rep->reply.errorCode = 0; From 6f01db228568789329eea47a5c72a241f09e7356 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 8 Dec 2006 16:15:59 +0100 Subject: [PATCH 11/40] ndb - bug#24914 Fix start transaction with hint from ndbapi --- storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 2 +- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 2098c196f2b..beb7e0ceb7b 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -479,7 +479,7 @@ Dbdict::packTableIntoPages(SimpleProperties::Writer & w, CreateFragmentationReq::SignalLength); ndbrequire(signal->theData[0] == 0); Uint16 *data = (Uint16*)&signal->theData[25]; - Uint32 count = 2 + data[0] * data[1]; + Uint32 count = 2 + (1 + data[0]) * data[1]; w.add(DictTabInfo::ReplicaDataLen, 2*count); for (Uint32 i = 0; i < count; i++) data[i] = htons(data[i]); diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 396d4417865..50c7c5472ba 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -6728,7 +6728,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal) FragmentstorePtr fragPtr; ReplicaRecordPtr replicaPtr; getFragstore(primTabPtr.p, fragNo, fragPtr); - fragments[count++] = c_nextLogPart++; + fragments[count++] = fragPtr.p->m_log_part_id; fragments[count++] = fragPtr.p->preferredPrimary; for (replicaPtr.i = fragPtr.p->storedReplicas; replicaPtr.i != RNIL; diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 40eb815d48b..4f6673cb468 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -2191,9 +2191,14 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, impl->m_replicaCount = replicaCount; impl->m_fragmentCount = fragCount; DBUG_PRINT("info", ("replicaCount=%x , fragCount=%x",replicaCount,fragCount)); - for(i = 0; i < (Uint32) (fragCount*replicaCount); i++) + Uint32 pos = 2; + for(i = 0; i < (Uint32) fragCount;i++) { - impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[i+2])); + pos++; // skip logpart + for (Uint32 j = 0; j<(Uint32)replicaCount; j++) + { + impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[pos++])); + } } Uint32 topBit = (1 << 31); From 3358f4f14b0b089a0a5af055d0fbfc3041def745 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 8 Dec 2006 17:21:29 +0100 Subject: [PATCH 12/40] ndb - bug#24917 --- storage/ndb/src/kernel/blocks/lgman.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/lgman.cpp b/storage/ndb/src/kernel/blocks/lgman.cpp index 50741f37fcf..17a4c4a4a83 100644 --- a/storage/ndb/src/kernel/blocks/lgman.cpp +++ b/storage/ndb/src/kernel/blocks/lgman.cpp @@ -2063,6 +2063,7 @@ Lgman::execSTART_RECREQ(Signal* signal) if(ptr.i != RNIL) { infoEvent("Applying undo to LCP: %d", m_latest_lcp); + ndbout_c("Applying undo to LCP: %d", m_latest_lcp); find_log_head(signal, ptr); return; } @@ -2682,13 +2683,14 @@ Lgman::execute_undo_record(Signal* signal) case File_formats::Undofile::UNDO_LCP_FIRST: { Uint32 lcp = * (ptr - len + 1); - if(lcp > m_latest_lcp) + if(m_latest_lcp && lcp > m_latest_lcp) { // Just ignore break; } - if(lcp < m_latest_lcp || + if(m_latest_lcp == 0 || + lcp < m_latest_lcp || (lcp == m_latest_lcp && mask == File_formats::Undofile::UNDO_LCP_FIRST)) { From 3c3f65c42b4a9d9f4696396c486f98d03597af76 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Sat, 9 Dec 2006 11:08:12 +0100 Subject: [PATCH 13/40] fix bug in make install --- mysql-test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index aa5c2106e8b..3034a0318fa 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -108,7 +108,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data - $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup50 $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51 From d5cd8df3bedf8a66ebe70e0edae6cb40d3ab682e Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Sat, 9 Dec 2006 11:45:33 +0100 Subject: [PATCH 14/40] ya typo --- mysql-test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 3034a0318fa..61c523f1aed 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -108,7 +108,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data - $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup50 $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51 From 7766aa089ec41f92a2b86de11ef20c4fae3510af Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Mon, 11 Dec 2006 16:18:34 +0100 Subject: [PATCH 15/40] ndb - bug#24664 Fix in bug fix, make sure LCP_SKIP is only used for inserts... --- storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index df8a035c442..3287c7422ff 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -302,7 +302,7 @@ Dbtup::commit_operation(Signal* signal, copy_bits |= Tuple_header::DISK_PART; } - if(lcpScan_ptr_i != RNIL) + if(lcpScan_ptr_i != RNIL && (bits & Tuple_header::ALLOC)) { ScanOpPtr scanOp; c_scanOpPool.getPtr(scanOp, lcpScan_ptr_i); From 6caf18ca8c818d218e5e0e5908531375ab0296ef Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 12 Dec 2006 13:07:22 +0100 Subject: [PATCH 16/40] ndb - style split assignment into 2 lines --- storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index ce7d87c9c82..a0565df0dfb 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -784,7 +784,8 @@ int Dbtup::updateAttributes(KeyReqStruct *req_struct, req_struct->m_tuple_ptr->m_header_bits |= Tuple_header::DISK_PART; memcpy(req_struct->m_tuple_ptr->get_disk_ref_ptr(regTabPtr), inBuffer+inBufIndex+1, sz << 2); - req_struct->in_buf_index = inBufIndex += 1 + sz; + inBufIndex += 1 + sz; + req_struct->in_buf_index = inBufIndex; } else { From 05dd5fc20cfc66f91b4c1f193308edc8a50eb3ff Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 12 Dec 2006 13:09:20 +0100 Subject: [PATCH 17/40] ndb - bug#25001 make sure DISK flag is set on DATA column for blob table --- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 8 ++++++-- storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 4f6673cb468..56c6258beec 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -2302,7 +2302,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) } // blob tables - use "t2" to get values set by kernel - if (t2->m_noOfBlobs != 0 && createBlobTables(*t2) != 0) { + if (t2->m_noOfBlobs != 0 && createBlobTables(t, *t2) != 0) { int save_code = m_error.code; (void)dropTableGlobal(*t2); m_error.code = save_code; @@ -2316,7 +2316,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) } int -NdbDictionaryImpl::createBlobTables(NdbTableImpl &t) +NdbDictionaryImpl::createBlobTables(NdbTableImpl& orig, NdbTableImpl &t) { DBUG_ENTER("NdbDictionaryImpl::createBlobTables"); for (unsigned i = 0; i < t.m_columns.size(); i++) { @@ -2325,6 +2325,10 @@ NdbDictionaryImpl::createBlobTables(NdbTableImpl &t) continue; NdbTableImpl bt; NdbBlob::getBlobTable(bt, &t, &c); + NdbDictionary::Column::StorageType + d = NdbDictionary::Column::StorageTypeDisk; + if (orig.m_columns[i]->getStorageType() == d) + bt.getColumn("DATA")->setStorageType(d); if (createTable(bt) != 0) { DBUG_RETURN(-1); } diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index e5f68cfcc81..c439a506051 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -582,7 +582,7 @@ public: bool setTransporter(class TransporterFacade * tf); int createTable(NdbTableImpl &t); - int createBlobTables(NdbTableImpl& t); + int createBlobTables(NdbTableImpl& org, NdbTableImpl& created); int alterTable(NdbTableImpl &t); int dropTable(const char * name); int dropTable(NdbTableImpl &); From 47a33ee5d0ad98bbab72ab19cbc8b115a9ace3ca Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 12 Dec 2006 16:21:06 +0100 Subject: [PATCH 18/40] ndb - bug#24949 make sure not too poll to long, in case of hb-failure of last db-node --- storage/ndb/src/ndbapi/Ndbif.cpp | 4 ++-- storage/ndb/src/ndbapi/TransporterFacade.cpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/storage/ndb/src/ndbapi/Ndbif.cpp b/storage/ndb/src/ndbapi/Ndbif.cpp index 599a38b287d..96417dd51de 100644 --- a/storage/ndb/src/ndbapi/Ndbif.cpp +++ b/storage/ndb/src/ndbapi/Ndbif.cpp @@ -1276,9 +1276,9 @@ Ndb::waitCompletedTransactions(int aMilliSecondsToWait, NDB_TICKS currTime = NdbTick_CurrentMillisecond(); NDB_TICKS maxTime = currTime + (NDB_TICKS)waitTime; theMinNoOfEventsToWakeUp = noOfEventsToWaitFor; + const int maxsleep = aMilliSecondsToWait > 10 ? 10 : aMilliSecondsToWait; do { - if (waitTime < 1000) waitTime = 1000; - poll_guard->wait_for_input(waitTime); + poll_guard->wait_for_input(maxsleep); if (theNoOfCompletedTransactions >= (Uint32)noOfEventsToWaitFor) { break; }//if diff --git a/storage/ndb/src/ndbapi/TransporterFacade.cpp b/storage/ndb/src/ndbapi/TransporterFacade.cpp index a2103c6107d..ddc6ca6dc56 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.cpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp @@ -1385,15 +1385,13 @@ int PollGuard::wait_for_input_in_loop(int wait_time, bool forceSend) m_tp->forceSend(m_block_no); else m_tp->checkForceSend(m_block_no); - if (wait_time == -1) //Means wait forever - response_time= WAITFOR_RESPONSE_TIMEOUT; - else - response_time= wait_time; + NDB_TICKS curr_time = NdbTick_CurrentMillisecond(); NDB_TICKS max_time = curr_time + (NDB_TICKS)wait_time; + const int maxsleep = (wait_time == -1 || wait_time > 10) ? 10 : wait_time; do { - wait_for_input(response_time); + wait_for_input(maxsleep); Uint32 state= m_waiter->get_state(); if (state == NO_WAIT) { From 2dbdd8ba58d395ac96ab9382af886a0dabacc152 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 13 Dec 2006 21:04:10 +0100 Subject: [PATCH 19/40] Remove old hack to avoid reception of SUB_DATA signals to destroyed Ndb object --- sql/ha_ndbcluster_binlog.cc | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 490114bf4a9..7e966497ed0 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -3958,10 +3958,6 @@ err: close_thread_tables(thd); pthread_mutex_lock(&injector_mutex); /* don't mess with the injector_ndb anymore from other threads */ - uint ndb_obj_cnt= 1; // g_ndb - ndb_obj_cnt+= injector_ndb == 0 ? 0 : 1; - ndb_obj_cnt+= schema_ndb == 0 ? 0 : 1; - ndb_obj_cnt+= ndbcluster_util_inited ? 1 : 0; injector_thd= 0; injector_ndb= 0; p_latest_trans_gci= 0; @@ -3969,29 +3965,8 @@ err: pthread_mutex_unlock(&injector_mutex); thd->db= 0; // as not to try to free memory - if (!ndb_extra_logging) - sql_print_information("Stopping Cluster Binlog"); - else - sql_print_information("Stopping Cluster Binlog: %u(%u)", - g_ndb_cluster_connection->get_active_ndb_objects(), - ndb_obj_cnt); + sql_print_information("Stopping Cluster Binlog"); - /** - * Add extra wait loop to make user "user" ndb-object go away... - * otherwise user thread can have ongoing SUB_DATA - */ - int sleep_cnt= 0; - while (sleep_cnt < 300 && - g_ndb_cluster_connection->get_active_ndb_objects() > ndb_obj_cnt) - { - my_sleep(10000); // 10ms - sleep_cnt++; - } - if (ndb_extra_logging) - sql_print_information("Stopping Cluster Binlog: waited %ums %u(%u)", - 10*sleep_cnt, g_ndb_cluster_connection->get_active_ndb_objects(), - ndb_obj_cnt); - if (ndb_apply_status_share) { free_share(&ndb_apply_status_share); From 8d8d063f9145ef21ce20b8455dac8936099397ec Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 14 Dec 2006 16:27:14 +0100 Subject: [PATCH 20/40] Removed check for impossible error return --- sql/ha_ndbcluster.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index ff5634d291c..149a7c83895 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2956,13 +2956,10 @@ KEY* key_info; DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); } else if (type == UNIQUE_INDEX) - { - error= unique_index_scan(key_info, - start_key->key, - start_key->length, - buf); - DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); - } + DBUG_RETURN(unique_index_scan(key_info, + start_key->key, + start_key->length, + buf)); break; default: break; From 856b919986e2f0d16f48fbb9e0ce7d50b020200c Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 14 Dec 2006 16:52:50 +0100 Subject: [PATCH 21/40] bug#19956 Problems with VARCHAR primary key and BLOB fields:put back removed error handling for HA_ERR_KEY_NOT_FOUND --- sql/ha_ndbcluster.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0362b8bf215..fb091664e93 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3478,8 +3478,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, { if (m_active_cursor && (error= close_scan())) DBUG_RETURN(error); - DBUG_RETURN(pk_read(start_key->key, start_key->length, buf, - part_spec.start_part)); + error= pk_read(start_key->key, start_key->length, buf, + part_spec.start_part); + DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); } break; case UNIQUE_ORDERED_INDEX: @@ -3490,7 +3491,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, { if (m_active_cursor && (error= close_scan())) DBUG_RETURN(error); - DBUG_RETURN(unique_index_read(start_key->key, start_key->length, buf)); + + error= unique_index_read(start_key->key, start_key->length, buf); + DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); } else if (type == UNIQUE_INDEX) DBUG_RETURN(unique_index_scan(key_info, From 532fe009b8ef06d723fb58fb9130c2a99707aefb Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Fri, 15 Dec 2006 09:03:21 +0100 Subject: [PATCH 22/40] bug#19956 Problems with VARCHAR primary key and BLOB fields:added test case --- mysql-test/r/ndb_read_multi_range.result | 14 ++++++++++++++ mysql-test/t/ndb_read_multi_range.test | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/mysql-test/r/ndb_read_multi_range.result b/mysql-test/r/ndb_read_multi_range.result index 9941d2b28a3..e2a076ef99f 100644 --- a/mysql-test/r/ndb_read_multi_range.result +++ b/mysql-test/r/ndb_read_multi_range.result @@ -367,3 +367,17 @@ a b c 406994 67 2006-02-27 11:26:46 406995 67 2006-02-28 11:55:00 DROP TABLE t1, t11, t12, t21, t22; +CREATE TABLE t1 (id varchar(255) NOT NULL, +tag int(11) NOT NULL, +doc text NOT NULL, +type varchar(150) NOT NULL, +modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (id) +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); +id tag doc type +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); +id tag doc type +sakila 1 Some text goes here text +DROP TABLE t1; diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test index 855f7789032..99edab5d23c 100644 --- a/mysql-test/t/ndb_read_multi_range.test +++ b/mysql-test/t/ndb_read_multi_range.test @@ -238,3 +238,18 @@ select * from t12 order by 1,2,3; select * from t21 order by 1,2,3; select * from t22 order by 1,2,3; DROP TABLE t1, t11, t12, t21, t22; + +# bug#19956 +CREATE TABLE t1 (id varchar(255) NOT NULL, + tag int(11) NOT NULL, + doc text NOT NULL, + type varchar(150) NOT NULL, + modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); + +DROP TABLE t1; From c9fe45e12a281128daf55d0b3db299eeb8e80fac Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 15 Dec 2006 12:37:55 +0100 Subject: [PATCH 23/40] ndb - bug#25090 make sure apicon timer is reset when setting CS_CONNECTED --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index a436316f7c9..1af8337e3b6 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -5220,6 +5220,8 @@ void Dbtc::execLQHKEYREF(Signal* signal) jam(); sendtckeyconf(signal, 1); regApiPtr->apiConnectstate = CS_CONNECTED; + regApiPtr->m_transaction_nodes.clear(); + setApiConTimer(apiConnectptr.i, 0,__LINE__); } return; } else if (regApiPtr->tckeyrec > 0 || regApiPtr->m_exec_flag) { From 5b16e6bf95c3cfd8694cbd6f55240a173b30e2d5 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 15 Dec 2006 13:31:31 +0100 Subject: [PATCH 24/40] ndb - bug#25090 add testcase --- ndb/test/ndbapi/testBasic.cpp | 26 +++++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/ndb/test/ndbapi/testBasic.cpp b/ndb/test/ndbapi/testBasic.cpp index 4d64b15ecfa..10235eef6d7 100644 --- a/ndb/test/ndbapi/testBasic.cpp +++ b/ndb/test/ndbapi/testBasic.cpp @@ -1034,6 +1034,28 @@ runMassiveRollback2(NDBT_Context* ctx, NDBT_Step* step){ return result; } +int +runBug25090(NDBT_Context* ctx, NDBT_Step* step){ + + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary * dict = pNdb->getDictionary(); + + HugoOperations ops(*ctx->getTab()); + + int loops = ctx->getNumLoops(); + const int rows = ctx->getNumRecords(); + + while (loops--) + { + ops.startTransaction(pNdb); + ops.pkReadRecord(pNdb, 1, 1); + ops.execute_Commit(pNdb, AO_IgnoreError); + sleep(10); + ops.closeTransaction(pNdb); + } + + return NDBT_OK; +} NDBT_TESTSUITE(testBasic); TESTCASE("PkInsert", @@ -1277,6 +1299,10 @@ TESTCASE("Fill", INITIALIZER(runPkRead); FINALIZER(runClearTable2); } +TESTCASE("Bug25090", + "Verify what happens when we fill the db" ){ + STEP(runBug25090); +} NDBT_TESTSUITE_END(testBasic); #if 0 diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 031c519ae6d..84982dd96f1 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -211,6 +211,10 @@ max-time: 500 cmd: testTimeout args: T1 +max-time: 500 +cmd: testBasic +args: -n Bug25090 T1 + # SCAN TESTS # max-time: 500 From b4d323c09aa2a6a2e2cf6968b9757153c7e0dee3 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 15 Dec 2006 15:39:45 +0100 Subject: [PATCH 25/40] ndb - bug#25059 incorrect handling of commit/ignore error in unique index code --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 15 +----- ndb/src/ndbapi/NdbTransaction.cpp | 9 ++++ ndb/src/ndbapi/Ndbif.cpp | 1 + ndb/test/ndbapi/testIndex.cpp | 65 +++++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++ 5 files changed, 81 insertions(+), 13 deletions(-) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 1af8337e3b6..9f1426109d4 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -5084,7 +5084,7 @@ void Dbtc::execLQHKEYREF(Signal* signal) ptrAss(tcConnectptr, tcConnectRecord); TcConnectRecord * const regTcPtr = tcConnectptr.p; if (regTcPtr->tcConnectstate == OS_OPERATING) { - apiConnectptr.i = regTcPtr->apiConnect; + Uint32 save = apiConnectptr.i = regTcPtr->apiConnect; ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord); ApiConnectRecord * const regApiPtr = apiConnectptr.p; compare_transid1 = regApiPtr->transid[0] ^ lqhKeyRef->transId1; @@ -5195,7 +5195,7 @@ void Dbtc::execLQHKEYREF(Signal* signal) regApiPtr->lqhkeyreqrec--; // Compensate for extra during read tcKeyRef->connectPtr = indexOp; EXECUTE_DIRECT(DBTC, GSN_TCKEYREF, signal, TcKeyRef::SignalLength); - apiConnectptr.i = regTcPtr->apiConnect; + apiConnectptr.i = save; apiConnectptr.p = regApiPtr; } else { jam(); @@ -11880,17 +11880,6 @@ void Dbtc::execTCKEYREF(Signal* signal) case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI): case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): { jam(); - // If we fail index access for a non-read operation during commit - // we abort transaction - if (commitFlg == 1) { - jam(); - releaseIndexOperation(regApiPtr, indexOp); - apiConnectptr.i = indexOp->connectionIndex; - ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord); - terrorCode = tcKeyRef->errorCode; - abortErrorLab(signal); - break; - } /** * Increase count as it will be decreased below... * (and the code is written to handle failing lookup on "real" table diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 62bbcefd025..1be11254fc3 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -474,6 +474,7 @@ NdbTransaction::executeNoBlobs(ExecType aTypeOfExec, * This timeout situation can occur if NDB crashes. */ ndbout << "This timeout should never occur, execute(..)" << endl; + theError.code = 4012; setOperationErrorCodeAbort(4012); // Error code for "Cluster Failure" DBUG_RETURN(-1); }//if @@ -1965,6 +1966,14 @@ NdbTransaction::receiveTCINDXCONF(const TcIndxConf * indxConf, theGlobalCheckpointId = tGCI; } else if ((tNoComp >= tNoSent) && (theLastExecOpInList->theCommitIndicator == 1)){ + + if (m_abortOption == AO_IgnoreError && theError.code != 0){ + /** + * There's always a TCKEYCONF when using IgnoreError + */ + return -1; + } + /**********************************************************************/ // We sent the transaction with Commit flag set and received a CONF with // no Commit flag set. This is clearly an anomaly. diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 6aaf44d0168..0c52e6bd120 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -952,6 +952,7 @@ Ndb::check_send_timeout() //abort(); #endif a_con->theReleaseOnClose = true; + a_con->theError.code = 4012; a_con->setOperationErrorCodeAbort(4012); a_con->theCommitStatus = NdbTransaction::NeedAbort; a_con->theCompletionStatus = NdbTransaction::CompletedFailure; diff --git a/ndb/test/ndbapi/testIndex.cpp b/ndb/test/ndbapi/testIndex.cpp index c25aae55897..bec649cf84d 100644 --- a/ndb/test/ndbapi/testIndex.cpp +++ b/ndb/test/ndbapi/testIndex.cpp @@ -1239,7 +1239,64 @@ runBug21384(NDBT_Context* ctx, NDBT_Step* step) return NDBT_OK; } +int +runBug25059(NDBT_Context* ctx, NDBT_Step* step) +{ + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary * dict = pNdb->getDictionary(); + const NdbDictionary::Index * idx = dict->getIndex(pkIdxName, *ctx->getTab()); + HugoOperations ops(*ctx->getTab(), idx); + + int res = NDBT_OK; + int loops = ctx->getNumLoops(); + const int rows = ctx->getNumRecords(); + + while (res == NDBT_OK && loops--) + { + ops.startTransaction(pNdb); + ops.pkReadRecord(pNdb, 10 + rand() % rows, rows); + int tmp; + if (tmp = ops.execute_Commit(pNdb, AO_IgnoreError)) + { + if (tmp == 4012) + res = NDBT_FAILED; + else + if (ops.getTransaction()->getNdbError().code == 4012) + res = NDBT_FAILED; + } + ops.closeTransaction(pNdb); + } + + loops = ctx->getNumLoops(); + while (res == NDBT_OK && loops--) + { + ops.startTransaction(pNdb); + ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows); + int tmp; + int arg; + switch(rand() % 2){ + case 0: + arg = AbortOnError; + break; + case 1: + arg = AO_IgnoreError; + ndbout_c("ignore error"); + break; + } + if (tmp = ops.execute_Commit(pNdb, (AbortOption)arg)) + { + if (tmp == 4012) + res = NDBT_FAILED; + else + if (ops.getTransaction()->getNdbError().code == 4012) + res = NDBT_FAILED; + } + ops.closeTransaction(pNdb); + } + + return res; +} NDBT_TESTSUITE(testIndex); TESTCASE("CreateAll", @@ -1564,6 +1621,14 @@ TESTCASE("Bug21384", FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable); } +TESTCASE("Bug25059", + "Test that unique indexes and nulls"){ + TC_PROPERTY("LoggedIndexes", (unsigned)0); + INITIALIZER(createPkIndex); + INITIALIZER(runLoadTable); + STEP(runBug25059); + FINALIZER(createPkIndex_Drop); +} NDBT_TESTSUITE_END(testIndex); int main(int argc, const char** argv){ diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 84982dd96f1..a1443970388 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -215,6 +215,10 @@ max-time: 500 cmd: testBasic args: -n Bug25090 T1 +max-time: 500 +cmd: testIndex +args: -n Bug25059 -r 3000 T1 + # SCAN TESTS # max-time: 500 From 2e375454196cf7970e9c2718d8fae54471372f4b Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 15 Dec 2006 17:12:41 +0100 Subject: [PATCH 26/40] merge fix --- storage/ndb/test/ndbapi/testIndex.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/ndb/test/ndbapi/testIndex.cpp b/storage/ndb/test/ndbapi/testIndex.cpp index bec649cf84d..a4733790e17 100644 --- a/storage/ndb/test/ndbapi/testIndex.cpp +++ b/storage/ndb/test/ndbapi/testIndex.cpp @@ -1244,7 +1244,8 @@ runBug25059(NDBT_Context* ctx, NDBT_Step* step) { Ndb* pNdb = GETNDB(step); NdbDictionary::Dictionary * dict = pNdb->getDictionary(); - const NdbDictionary::Index * idx = dict->getIndex(pkIdxName, *ctx->getTab()); + const NdbDictionary::Index * idx = dict->getIndex(pkIdxName, + ctx->getTab()->getName()); HugoOperations ops(*ctx->getTab(), idx); From 5b7c2c91c187af254a42f3783fcde626b0e9d380 Mon Sep 17 00:00:00 2001 From: "skozlov/ksm@mysql.com/virtop.localdomain" <> Date: Sun, 17 Dec 2006 23:08:04 +0300 Subject: [PATCH 27/40] WL#2862 --- mysql-test/r/ndb_alter_table.result | 45 +++++++++++++++++ mysql-test/r/ndb_basic.result | 76 +++++++++++++++++++++++++++++ mysql-test/r/ndb_cursor.result | 39 +++++++++++++++ mysql-test/r/ndb_sp.result | 45 +++++++++++++++++ mysql-test/r/ndb_subquery.result | 39 +++++++++++++-- mysql-test/r/ndb_trigger.result | 31 ++++++++++-- mysql-test/t/ndb_alter_table.test | 27 ++++++++++ mysql-test/t/ndb_basic.test | 53 ++++++++++++++++++++ mysql-test/t/ndb_cursor.test | 46 +++++++++++++++++ mysql-test/t/ndb_sp.test | 43 ++++++++++++++++ mysql-test/t/ndb_subquery.test | 18 +++++-- mysql-test/t/ndb_trigger.test | 30 ++++++++++-- 12 files changed, 477 insertions(+), 15 deletions(-) create mode 100644 mysql-test/r/ndb_cursor.result create mode 100644 mysql-test/r/ndb_sp.result create mode 100644 mysql-test/t/ndb_cursor.test create mode 100644 mysql-test/t/ndb_sp.test diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index 7facb5fa286..be258f41c52 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -354,3 +354,48 @@ select * from t1 where a = 12; a b c 12 403 NULL drop table t1; +create table t1 (a int not null, b varchar(10)) engine=ndb; +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +alter table t1 add primary key (a); +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE +alter table t1 drop primary key; +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +drop table t1; +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) NOT NULL DEFAULT '0', + `c` varchar(254) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +alter table t1 alter b set default 1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) NOT NULL DEFAULT '1', + `c` varchar(254) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int not null, b int not null) engine=ndb; +insert into t1 values (1, 300), (2, 200), (3, 100); +select * from t1; +a b +3 100 +2 200 +1 300 +alter table t1 order by b; +select * from t1; +a b +1 300 +2 200 +3 100 +drop table t1; +End of 5.1 tests diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index b7e893faf29..821b80e349b 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -773,4 +773,80 @@ a b 2 2 3 3 drop table t1, t2; +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table t2 like t1; +rename table t1 to t10, t2 to t20; +drop table t10,t20; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 20 +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +a b +3 30 +drop table t1,t2; +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t1 set a=1, b=100; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +a b +1 11 +2 20 +3 30 +drop table t1; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +update t1 set a = 1 where a = 3; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 30 +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +a b +1 10 +2 10 +3 1 +4 1 +drop table t1,t2; End of 5.1 tests diff --git a/mysql-test/r/ndb_cursor.result b/mysql-test/r/ndb_cursor.result new file mode 100644 index 00000000000..d11c549d45e --- /dev/null +++ b/mysql-test/r/ndb_cursor.result @@ -0,0 +1,39 @@ +drop table if exists t1; +drop table if exists t2; +create table t1 ( +a int not null primary key, +b int not null +) engine=ndb; +create table t2 ( +a int not null primary key, +b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30), (4, 40); +create procedure test_cursor () +begin +declare done int default 0; +declare temp_a int; +declare temp_b int; +declare cur1 cursor for select a,b from t1; +declare continue handler for sqlstate '02000' set done = 1; +open cur1; +repeat +fetch cur1 into temp_a, temp_b; +if not done then +insert into t2 values (temp_a, temp_b); +end if; +until done end repeat; +close cur1; +end; +// +select * from t2 order by a; +a b +call test_cursor(); +select * from t2 order by a; +a b +1 10 +2 20 +3 30 +4 40 +drop table t1,t2; +end of 5.1 tests diff --git a/mysql-test/r/ndb_sp.result b/mysql-test/r/ndb_sp.result new file mode 100644 index 00000000000..847b3a7eb0f --- /dev/null +++ b/mysql-test/r/ndb_sp.result @@ -0,0 +1,45 @@ +drop table if exists t1; +drop table if exists t2; +create table t1 ( +a int not null primary key, +b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,100), (4, 100); +create procedure test_proc1 (in var_in int) +begin +select * from t1 where a = var_in; +end; +create procedure test_proc2 (out var_out int) +begin +select b from t1 where a = 1 into var_out; +end; +create procedure test_proc3 (inout var_inout int) +begin +select b from t1 where a = var_inout into var_inout; +end; +// +call test_proc1(1); +a b +1 10 +call test_proc2(@test_var); +select @test_var; +@test_var +10 +set @test_var = 1; +call test_proc3(@test_var); +select @test_var; +@test_var +10 +alter procedure test_proc1 comment 'new comment'; +show create procedure test_proc1; +Procedure sql_mode Create Procedure +test_proc1 CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc1`(in var_in int) + COMMENT 'new comment' +begin +select * from t1 where a = var_in; +end +drop procedure test_proc1; +drop procedure test_proc2; +drop procedure test_proc3; +drop table t1; +End of 5.1 tests diff --git a/mysql-test/r/ndb_subquery.result b/mysql-test/r/ndb_subquery.result index 312711ab4b7..f2c9972f774 100644 --- a/mysql-test/r/ndb_subquery.result +++ b/mysql-test/r/ndb_subquery.result @@ -1,11 +1,14 @@ -drop table if exists t1; -drop table if exists t2; +drop table if exists t1, t2, t3, t4; create table t1 (p int not null primary key, u int not null, o int not null, unique (u), key(o)) engine=ndb; create table t2 (p int not null primary key, u int not null, o int not null, unique (u), key(o)) engine=ndb; +create table t3 (a int not null primary key, b int not null) engine=ndb; +create table t4 (c int not null primary key, d int not null) engine=ndb; insert into t1 values (1,1,1),(2,2,2),(3,3,3); insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); +insert into t3 values (1,10), (2,10), (3,30), (4, 30); +insert into t4 values (1,10), (2,10), (3,30), (4, 30); explain select * from t2 where p NOT IN (select p from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where @@ -57,5 +60,33 @@ p u 1 1 2 2 3 3 -drop table t1; -drop table t2; +select * from t3 where a = any (select c from t4 where c = 1) order by a; +a b +1 10 +select * from t3 where a in (select c from t4 where c = 1) order by a; +a b +1 10 +select * from t3 where a <> some (select c from t4 where c = 1) order by a; +a b +2 10 +3 30 +4 30 +select * from t3 where a > all (select c from t4 where c = 1) order by a; +a b +2 10 +3 30 +4 30 +select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a; +a b +1 10 +2 10 +3 30 +4 30 +select * from t3 where exists (select * from t4 where c = 1) order by a; +a b +1 10 +2 10 +3 30 +4 30 +drop table if exists t1, t2, t3, t4; +End of 5.1 tests diff --git a/mysql-test/r/ndb_trigger.result b/mysql-test/r/ndb_trigger.result index 27f83df70c9..2aeca5db2d3 100644 --- a/mysql-test/r/ndb_trigger.result +++ b/mysql-test/r/ndb_trigger.result @@ -1,7 +1,9 @@ -drop table if exists t1, t2, t3; +drop table if exists t1, t2, t3, t4, t5; create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb; create table t2 (op char(1), a int not null, b decimal (63,30)); create table t3 select 1 as i; +create table t4 (a int not null primary key, b int) engine=ndb; +create table t5 (a int not null primary key, b int) engine=ndb; create trigger t1_bu before update on t1 for each row begin insert into t2 values ("u", old.a, old.b); @@ -11,7 +13,19 @@ create trigger t1_bd before delete on t1 for each row begin insert into t2 values ("d", old.a, old.b); end;// +create trigger t4_au after update on t4 +for each row begin +update t5 set b = b+1; +end; +// +create trigger t4_ad after delete on t4 +for each row begin +update t5 set b = b+1; +end; +// insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05); +insert into t4 values (1,1), (2,2), (3,3), (4, 4); +insert into t5 values (1,0); update t1 set a=5 where a != 3; select * from t1 order by id; id a b @@ -115,5 +129,16 @@ select * from t2 order by op, a, b; op a b d 1 1.050000000000000000000000000000 d 2 2.050000000000000000000000000000 -drop tables t1, t2, t3; -End of 5.0 tests +update t4 set b = 10 where a = 1; +select * from t5 order by a; +a b +1 1 +update t5 set b = 0; +delete from t4 where a = 1; +select * from t5 order by a; +a b +1 1 +drop trigger t4_au; +drop trigger t4_ad; +drop table t1, t2, t3, t4, t5; +End of 5.1 tests diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index fde9f1479f8..28a03cb4595 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -410,3 +410,30 @@ alter table t2 rename t1; insert into t1 (b) values (401),(402),(403); select * from t1 where a = 12; drop table t1; + +# some other ALTER combinations +# add/drop pk +create table t1 (a int not null, b varchar(10)) engine=ndb; +show index from t1; +alter table t1 add primary key (a); +show index from t1; +alter table t1 drop primary key; +show index from t1; +drop table t1; + +# alter .. alter +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +show create table t1; +alter table t1 alter b set default 1; +show create table t1; +drop table t1; + +# alter .. order by +create table t1 (a int not null, b int not null) engine=ndb; +insert into t1 values (1, 300), (2, 200), (3, 100); +select * from t1; +alter table t1 order by b; +select * from t1; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 3348a94c044..8541c0ac0c5 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -747,4 +747,57 @@ select * from t1 order by a; select * from t2 order by a; drop table t1, t2; +# create table if not exists +--disable_warnings +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +--enable_warnings + +# create like +create table t2 like t1; + +# multi rename +rename table t1 to t10, t2 to t20; +drop table t10,t20; + +# delete +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +drop table t1,t2; + +# insert ignore +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +--error 1062 +insert into t1 set a=1, b=100; +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +drop table t1; + +# update +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +--error 1062 +update t1 set a = 1 where a = 3; +select * from t1 order by a; +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +--error 1062 +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +drop table t1,t2; + --echo End of 5.1 tests diff --git a/mysql-test/t/ndb_cursor.test b/mysql-test/t/ndb_cursor.test new file mode 100644 index 00000000000..88ebf283e6d --- /dev/null +++ b/mysql-test/t/ndb_cursor.test @@ -0,0 +1,46 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings + +create table t1 ( + a int not null primary key, + b int not null +) engine=ndb; + +create table t2 ( + a int not null primary key, + b int not null +) engine=ndb; + +insert into t1 values (1,10), (2,20), (3,30), (4, 40); + +delimiter //; +create procedure test_cursor () +begin + declare done int default 0; + declare temp_a int; + declare temp_b int; + declare cur1 cursor for select a,b from t1; + declare continue handler for sqlstate '02000' set done = 1; + open cur1; + repeat + fetch cur1 into temp_a, temp_b; + if not done then + insert into t2 values (temp_a, temp_b); + end if; + until done end repeat; + close cur1; +end; +// +delimiter ;// + +select * from t2 order by a; +call test_cursor(); +select * from t2 order by a; +drop table t1,t2; + +--echo end of 5.1 tests diff --git a/mysql-test/t/ndb_sp.test b/mysql-test/t/ndb_sp.test new file mode 100644 index 00000000000..754f1e94e66 --- /dev/null +++ b/mysql-test/t/ndb_sp.test @@ -0,0 +1,43 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings + +create table t1 ( + a int not null primary key, + b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,100), (4, 100); + +delimiter //; +create procedure test_proc1 (in var_in int) +begin + select * from t1 where a = var_in; +end; +create procedure test_proc2 (out var_out int) +begin + select b from t1 where a = 1 into var_out; +end; +create procedure test_proc3 (inout var_inout int) +begin + select b from t1 where a = var_inout into var_inout; +end; +// +delimiter ;// +call test_proc1(1); +call test_proc2(@test_var); +select @test_var; +set @test_var = 1; +call test_proc3(@test_var); +select @test_var; +alter procedure test_proc1 comment 'new comment'; +show create procedure test_proc1; +drop procedure test_proc1; +drop procedure test_proc2; +drop procedure test_proc3; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test index 9cf6527dd98..6282c31c922 100644 --- a/mysql-test/t/ndb_subquery.test +++ b/mysql-test/t/ndb_subquery.test @@ -2,8 +2,7 @@ -- source include/not_embedded.inc --disable_warnings -drop table if exists t1; -drop table if exists t2; +drop table if exists t1, t2, t3, t4; --enable_warnings ########## @@ -14,8 +13,13 @@ unique (u), key(o)) engine=ndb; create table t2 (p int not null primary key, u int not null, o int not null, unique (u), key(o)) engine=ndb; +create table t3 (a int not null primary key, b int not null) engine=ndb; +create table t4 (c int not null primary key, d int not null) engine=ndb; + insert into t1 values (1,1,1),(2,2,2),(3,3,3); insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); +insert into t3 values (1,10), (2,10), (3,30), (4, 30); +insert into t4 values (1,10), (2,10), (3,30), (4, 30); # Use pk --replace_column 9 # @@ -63,7 +67,13 @@ where t1.u = t2.u select * from t2 order by 1; -drop table t1; -drop table t2; +select * from t3 where a = any (select c from t4 where c = 1) order by a; +select * from t3 where a in (select c from t4 where c = 1) order by a; +select * from t3 where a <> some (select c from t4 where c = 1) order by a; +select * from t3 where a > all (select c from t4 where c = 1) order by a; +select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a; +select * from t3 where exists (select * from t4 where c = 1) order by a; +drop table if exists t1, t2, t3, t4; +--echo End of 5.1 tests diff --git a/mysql-test/t/ndb_trigger.test b/mysql-test/t/ndb_trigger.test index 2521ef17842..7a4e58033a9 100644 --- a/mysql-test/t/ndb_trigger.test +++ b/mysql-test/t/ndb_trigger.test @@ -14,13 +14,15 @@ # --disable_warnings -drop table if exists t1, t2, t3; +drop table if exists t1, t2, t3, t4, t5; --enable_warnings create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb; create table t2 (op char(1), a int not null, b decimal (63,30)); create table t3 select 1 as i; - +create table t4 (a int not null primary key, b int) engine=ndb; +create table t5 (a int not null primary key, b int) engine=ndb; + delimiter //; create trigger t1_bu before update on t1 for each row begin @@ -31,8 +33,21 @@ create trigger t1_bd before delete on t1 for each row begin insert into t2 values ("d", old.a, old.b); end;// +create trigger t4_au after update on t4 + for each row begin + update t5 set b = b+1; + end; +// +create trigger t4_ad after delete on t4 + for each row begin + update t5 set b = b+1; + end; +// delimiter ;// + insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05); +insert into t4 values (1,1), (2,2), (3,3), (4, 4); +insert into t5 values (1,0); # Check that usual update works as it should update t1 set a=5 where a != 3; @@ -86,7 +101,14 @@ insert into t1 values (3, 1, 1.05), (5, 2, 2.05); load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (id, a); select * from t1 order by id; select * from t2 order by op, a, b; +update t4 set b = 10 where a = 1; +select * from t5 order by a; +update t5 set b = 0; +delete from t4 where a = 1; +select * from t5 order by a; +drop trigger t4_au; +drop trigger t4_ad; -drop tables t1, t2, t3; +drop table t1, t2, t3, t4, t5; ---echo End of 5.0 tests +--echo End of 5.1 tests From 4843e335fccdf61a1adf06bd79854198f19119e1 Mon Sep 17 00:00:00 2001 From: "skozlov/ksm@mysql.com/virtop.localdomain" <> Date: Mon, 18 Dec 2006 09:46:44 +0300 Subject: [PATCH 28/40] fix for commit 1.2368 --- mysql-test/r/ndb_alter_table.result | 12 ++++++------ mysql-test/t/ndb_alter_table.test | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index be258f41c52..13c445b44ca 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -386,16 +386,16 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (a int not null, b int not null) engine=ndb; insert into t1 values (1, 300), (2, 200), (3, 100); -select * from t1; +select * from t1 order by a; a b -3 100 -2 200 1 300 +2 200 +3 100 alter table t1 order by b; -select * from t1; +select * from t1 order by b; a b -1 300 -2 200 3 100 +2 200 +1 300 drop table t1; End of 5.1 tests diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 28a03cb4595..a7b52d54710 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -431,9 +431,9 @@ drop table t1; # alter .. order by create table t1 (a int not null, b int not null) engine=ndb; insert into t1 values (1, 300), (2, 200), (3, 100); -select * from t1; +select * from t1 order by a; alter table t1 order by b; -select * from t1; +select * from t1 order by b; drop table t1; --echo End of 5.1 tests From 1f10aa10d9613b13275b2943f5b8a82009bf1eca Mon Sep 17 00:00:00 2001 From: "skozlov/ksm@mysql.com/virtop.localdomain" <> Date: Mon, 18 Dec 2006 12:52:59 +0300 Subject: [PATCH 29/40] fix for commit 1.2368 --- mysql-test/r/ndb_cursor.result | 1 + mysql-test/t/ndb_cursor.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/ndb_cursor.result b/mysql-test/r/ndb_cursor.result index d11c549d45e..b3b815ef891 100644 --- a/mysql-test/r/ndb_cursor.result +++ b/mysql-test/r/ndb_cursor.result @@ -35,5 +35,6 @@ a b 2 20 3 30 4 40 +drop procedure test_cursor; drop table t1,t2; end of 5.1 tests diff --git a/mysql-test/t/ndb_cursor.test b/mysql-test/t/ndb_cursor.test index 88ebf283e6d..406f8629cfe 100644 --- a/mysql-test/t/ndb_cursor.test +++ b/mysql-test/t/ndb_cursor.test @@ -41,6 +41,7 @@ delimiter ;// select * from t2 order by a; call test_cursor(); select * from t2 order by a; +drop procedure test_cursor; drop table t1,t2; --echo end of 5.1 tests From 74a5079fa0d93f92c53edc4016a17723c9f88e38 Mon Sep 17 00:00:00 2001 From: "skozlov/ksm@mysql.com/virtop.localdomain" <> Date: Tue, 19 Dec 2006 16:17:57 +0300 Subject: [PATCH 30/40] WL#2862 ndb_sp.test - removed unnecessary line --- mysql-test/r/ndb_sp.result | 1 - mysql-test/t/ndb_sp.test | 1 - 2 files changed, 2 deletions(-) diff --git a/mysql-test/r/ndb_sp.result b/mysql-test/r/ndb_sp.result index 847b3a7eb0f..32e6d2eddd7 100644 --- a/mysql-test/r/ndb_sp.result +++ b/mysql-test/r/ndb_sp.result @@ -1,5 +1,4 @@ drop table if exists t1; -drop table if exists t2; create table t1 ( a int not null primary key, b int not null diff --git a/mysql-test/t/ndb_sp.test b/mysql-test/t/ndb_sp.test index 754f1e94e66..b833869cad0 100644 --- a/mysql-test/t/ndb_sp.test +++ b/mysql-test/t/ndb_sp.test @@ -3,7 +3,6 @@ --disable_warnings drop table if exists t1; -drop table if exists t2; --enable_warnings create table t1 ( From dab48d5df2d227b94a361808709bf02e0c76ca39 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 19 Dec 2006 15:53:46 +0100 Subject: [PATCH 31/40] bug#24667 After ALTER TABLE operation ndb_dd table becomes regular ndb: copy tablespace from old table in copying alter table --- mysql-test/r/ndb_dd_alter.result | 14 ++++++++++---- mysql-test/t/ndb_dd_alter.test | 4 ++++ sql/ha_ndbcluster.cc | 10 ++++++++-- sql/ha_ndbcluster.h | 2 +- sql/handler.h | 2 +- sql/sql_show.cc | 4 ++-- sql/sql_table.cc | 11 ++++++++++- 7 files changed, 36 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/ndb_dd_alter.result b/mysql-test/r/ndb_dd_alter.result index a9505747a94..fec4e5496ad 100644 --- a/mysql-test/r/ndb_dd_alter.result +++ b/mysql-test/r/ndb_dd_alter.result @@ -282,7 +282,13 @@ a1 18 19 20 +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE; +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts SELECT * FROM test.t1 ORDER BY a1; a1 a2 a3 1 2.2345 20000001 @@ -369,7 +375,7 @@ t1 CREATE TABLE `t1` ( `a13` text, `a14` blob, PRIMARY KEY (`a1`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ADD INDEX a2_i (a2), ADD INDEX a3_i (a3); SHOW CREATE TABLE test.t1; Table Create Table @@ -391,7 +397,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a1`), KEY `a2_i` (`a2`), KEY `a3_i` (`a3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 DROP INDEX a2_i; SHOW CREATE TABLE test.t1; Table Create Table @@ -412,7 +418,7 @@ t1 CREATE TABLE `t1` ( `a14` blob, PRIMARY KEY (`a1`), KEY `a3_i` (`a3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 DROP a14; ALTER TABLE test.t1 DROP a13; ALTER TABLE test.t1 DROP a12; @@ -432,7 +438,7 @@ t1 CREATE TABLE `t1` ( `a4` bit(1) DEFAULT NULL, `a5` tinyint(4) DEFAULT NULL, KEY `a3_i` (`a3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP TABLE test.t1; ALTER TABLESPACE ts DROP DATAFILE './table_space/datafile.dat' diff --git a/mysql-test/t/ndb_dd_alter.test b/mysql-test/t/ndb_dd_alter.test index 4eb76fc1ad6..6a9bdb79f6f 100644 --- a/mysql-test/t/ndb_dd_alter.test +++ b/mysql-test/t/ndb_dd_alter.test @@ -156,8 +156,12 @@ enable_query_log; SELECT * FROM test.t1 ORDER BY a1; +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; + ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE; +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; + let $1=20; disable_query_log; while ($1) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index fb091664e93..b2a4357425b 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -9949,7 +9949,7 @@ int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op, /* get table space info for SHOW CREATE TABLE */ -char* ha_ndbcluster::get_tablespace_name(THD *thd) +char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name) { Ndb *ndb= check_ndb_in_thd(thd); NDBDICT *ndbdict= ndb->getDictionary(); @@ -9967,7 +9967,13 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd) ndberr= ndbdict->getNdbError(); if(ndberr.classification != NdbError::NoError) goto err; - return (my_strdup(ts.getName(), MYF(0))); + if (name) + { + strxnmov(name, FN_LEN, ts.getName(), NullS); + return name; + } + else + return (my_strdup(ts.getName(), MYF(0))); } err: if (ndberr.status == NdbError::TemporaryError) diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index ed9e5ea41cc..54c642e8273 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -824,7 +824,7 @@ private: uint set_up_partition_info(partition_info *part_info, TABLE *table, void *tab); - char* get_tablespace_name(THD *thd); + char* get_tablespace_name(THD *thd, char *name); int set_range_data(void *tab, partition_info* part_info); int set_list_data(void *tab, partition_info* part_info); int complemented_read(const byte *old_data, byte *new_data, diff --git a/sql/handler.h b/sql/handler.h index f27912f4d1e..b9411ba108a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1410,7 +1410,7 @@ public: { return FALSE; } virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ - virtual char* get_tablespace_name(THD *thd) + virtual char* get_tablespace_name(THD *thd, char *name) { return(NULL);} /* gets tablespace name from handler */ /* used in ALTER TABLE; 1 if changing storage engine is allowed */ virtual bool can_switch_engines() { return 1; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0ebccba43ca..af02ccf1348 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1267,7 +1267,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, to the CREATE TABLE statement */ - if ((for_str= file->get_tablespace_name(thd))) + if ((for_str= file->get_tablespace_name(thd,0))) { packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE ")); packet->append(for_str, strlen(for_str)); @@ -3974,7 +3974,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, strlen(part_elem->tablespace_name), cs); else { - char *ts= showing_table->file->get_tablespace_name(thd); + char *ts= showing_table->file->get_tablespace_name(thd,0); if(ts) { table->field[24]->store(ts, strlen(ts), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c8f6e09fecb..930c84361ed 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5307,7 +5307,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, int error; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; - char index_file[FN_REFLEN], data_file[FN_REFLEN]; + char index_file[FN_REFLEN], data_file[FN_REFLEN], tablespace[FN_LEN]; char path[FN_REFLEN]; char reg_path[FN_REFLEN+1]; ha_rows copied,deleted; @@ -5630,6 +5630,15 @@ view_err: if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) create_info->key_block_size= table->s->key_block_size; + if (!create_info->tablespace) + { + /* + Regular alter table of disk stored table (no tablespace change) + Copy tablespace name + */ + if (table->file->get_tablespace_name(thd, (char *) &tablespace)) + create_info->tablespace= (char *) &tablespace; + } restore_record(table, s->default_values); // Empty record for DEFAULT List_iterator drop_it(alter_info->drop_list); List_iterator def_it(fields); From 3587ee8e4e02d4c6d0b590c4b017606453f8414c Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 19 Dec 2006 23:20:43 +0100 Subject: [PATCH 32/40] bug#24667 After ALTER TABLE operation ndb_dd table becomes regular ndb: ALTER TABLE must specify STORAGE explicitely to change it, + post review changes --- include/my_base.h | 8 ++++++++ mysql-test/r/ndb_dd_disk2memory.result | 4 ++-- mysql-test/r/rpl_ndb_dd_advance.result | 12 ++++++------ mysql-test/t/ndb_dd_disk2memory.test | 2 +- sql/ha_ndbcluster.cc | 10 +++++----- sql/ha_ndbcluster.h | 2 +- sql/handler.h | 4 ++-- sql/sql_show.cc | 4 ++-- sql/sql_table.cc | 8 ++++---- sql/sql_yacc.yy | 6 ++++-- 10 files changed, 35 insertions(+), 25 deletions(-) diff --git a/include/my_base.h b/include/my_base.h index cf254f5e0d0..9620acedb75 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -96,6 +96,14 @@ enum ha_key_alg { HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */ }; + /* Storage media types */ + +enum ha_storage_media { + HA_SM_DEFAULT= 0, /* Not specified (engine default) */ + HA_SM_DISK= 1, /* DISK storage */ + HA_SM_MEMORY= 2 /* MAIN MEMORY storage */ +}; + /* The following is parameter to ha_extra() */ enum ha_extra_function { diff --git a/mysql-test/r/ndb_dd_disk2memory.result b/mysql-test/r/ndb_dd_disk2memory.result index 9da506bf743..46661f36d1b 100644 --- a/mysql-test/r/ndb_dd_disk2memory.result +++ b/mysql-test/r/ndb_dd_disk2memory.result @@ -237,7 +237,7 @@ t2 CREATE TABLE `t2` ( `c2` int(11) NOT NULL, PRIMARY KEY (`pk2`) ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 -ALTER TABLE test.t1 ENGINE=NDBCLUSTER; +ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER; SHOW CREATE TABLE test.t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -341,7 +341,7 @@ t1 CREATE TABLE `t1` ( KEY `a2` (`a2`), KEY `a3` (`a3`), KEY `a8` (`a8`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 Table Create Table t2 CREATE TABLE `t2` ( `b1` smallint(6) NOT NULL, diff --git a/mysql-test/r/rpl_ndb_dd_advance.result b/mysql-test/r/rpl_ndb_dd_advance.result index c52fe7114c4..a4614b4b484 100644 --- a/mysql-test/r/rpl_ndb_dd_advance.result +++ b/mysql-test/r/rpl_ndb_dd_advance.result @@ -70,7 +70,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`), KEY `c5` (`c5`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Show first set of ALTERs on SLAVE **** SHOW CREATE TABLE t1; Table Create Table @@ -83,7 +83,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`), KEY `c5` (`c5`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Second set of alters test 1 **** ALTER TABLE t1 RENAME t2; ALTER TABLE t2 DROP INDEX c5; @@ -102,7 +102,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Show second set of ALTERs on SLAVE **** SHOW CREATE TABLE t1; Table Create Table @@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Third and last set of alters for test1 **** ALTER TABLE t1 CHANGE c1 c1 DOUBLE; ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2); @@ -136,7 +136,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 SELECT * FROM t1 ORDER BY c1 LIMIT 5; c1 c2 c3 c5 1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL @@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 SELECT * FROM t1 where c1 = 1; c1 c2 c3 c5 1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL diff --git a/mysql-test/t/ndb_dd_disk2memory.test b/mysql-test/t/ndb_dd_disk2memory.test index 0f819b54fb2..5975f44e087 100644 --- a/mysql-test/t/ndb_dd_disk2memory.test +++ b/mysql-test/t/ndb_dd_disk2memory.test @@ -111,7 +111,7 @@ SHOW CREATE TABLE test.t1; ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; SHOW CREATE TABLE test.t2; -ALTER TABLE test.t1 ENGINE=NDBCLUSTER; +ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER; SHOW CREATE TABLE test.t1; --echo ######################### End Test Section 2 ################# diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index b2a4357425b..f83589dd758 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4807,7 +4807,7 @@ int ha_ndbcluster::create(const char *name, if ((my_errno= create_ndb_column(col, field, info))) DBUG_RETURN(my_errno); - if (info->store_on_disk || getenv("NDB_DEFAULT_DISK")) + if (info->storage_media == HA_SM_DISK || getenv("NDB_DEFAULT_DISK")) col.setStorageType(NdbDictionary::Column::StorageTypeDisk); else col.setStorageType(NdbDictionary::Column::StorageTypeMemory); @@ -4827,7 +4827,7 @@ int ha_ndbcluster::create(const char *name, NdbDictionary::Column::StorageTypeMemory); } - if (info->store_on_disk) + if (info->storage_media == HA_SM_DISK) { if (info->tablespace) tab.setTablespace(info->tablespace); @@ -4837,7 +4837,7 @@ int ha_ndbcluster::create(const char *name, else if (info->tablespace) { tab.setTablespace(info->tablespace); - info->store_on_disk = true; //if use tablespace, that also means store on disk + info->storage_media = HA_SM_DISK; //if use tablespace, that also means store on disk } // No primary key, create shadow key as 64 bit, auto increment @@ -9949,7 +9949,7 @@ int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op, /* get table space info for SHOW CREATE TABLE */ -char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name) +char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len) { Ndb *ndb= check_ndb_in_thd(thd); NDBDICT *ndbdict= ndb->getDictionary(); @@ -9969,7 +9969,7 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name) goto err; if (name) { - strxnmov(name, FN_LEN, ts.getName(), NullS); + strxnmov(name, name_len, ts.getName(), NullS); return name; } else diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 54c642e8273..6af97aa3cea 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -824,7 +824,7 @@ private: uint set_up_partition_info(partition_info *part_info, TABLE *table, void *tab); - char* get_tablespace_name(THD *thd, char *name); + char* get_tablespace_name(THD *thd, char *name, uint name_len); int set_range_data(void *tab, partition_info* part_info); int set_list_data(void *tab, partition_info* part_info); int complemented_read(const byte *old_data, byte *new_data, diff --git a/sql/handler.h b/sql/handler.h index b9411ba108a..1bd87ac2afa 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -764,7 +764,7 @@ typedef struct st_ha_create_information bool table_existed; /* 1 in create if table existed */ bool frm_only; /* 1 if no ha_create_table() */ bool varchar; /* 1 if table has a VARCHAR */ - bool store_on_disk; /* 1 if table stored on disk */ + enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */ } HA_CREATE_INFO; @@ -1410,7 +1410,7 @@ public: { return FALSE; } virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ - virtual char* get_tablespace_name(THD *thd, char *name) + virtual char* get_tablespace_name(THD *thd, char *name, uint name_len) { return(NULL);} /* gets tablespace name from handler */ /* used in ALTER TABLE; 1 if changing storage engine is allowed */ virtual bool can_switch_engines() { return 1; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index af02ccf1348..d7ae859875a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1267,7 +1267,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, to the CREATE TABLE statement */ - if ((for_str= file->get_tablespace_name(thd,0))) + if ((for_str= file->get_tablespace_name(thd,0,0))) { packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE ")); packet->append(for_str, strlen(for_str)); @@ -3974,7 +3974,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, strlen(part_elem->tablespace_name), cs); else { - char *ts= showing_table->file->get_tablespace_name(thd,0); + char *ts= showing_table->file->get_tablespace_name(thd,0,0); if(ts) { table->field[24]->store(ts, strlen(ts), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 930c84361ed..8e846d10194 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5630,14 +5630,14 @@ view_err: if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) create_info->key_block_size= table->s->key_block_size; - if (!create_info->tablespace) + if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY) { /* - Regular alter table of disk stored table (no tablespace change) + Regular alter table of disk stored table (no tablespace/storage change) Copy tablespace name */ - if (table->file->get_tablespace_name(thd, (char *) &tablespace)) - create_info->tablespace= (char *) &tablespace; + if ((table->file->get_tablespace_name(thd, tablespace, FN_LEN))) + create_info->tablespace= tablespace; } restore_record(table, s->default_values); // Empty record for DEFAULT List_iterator drop_it(alter_info->drop_list); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 704c505ded9..34c7130d8ed 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3947,8 +3947,8 @@ create_table_option: | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR; } | INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR; } | TABLESPACE ident {Lex->create_info.tablespace= $2.str;} - | STORAGE_SYM DISK_SYM {Lex->create_info.store_on_disk= TRUE;} - | STORAGE_SYM MEMORY_SYM {Lex->create_info.store_on_disk= FALSE;} + | STORAGE_SYM DISK_SYM {Lex->create_info.storage_media= HA_SM_DISK;} + | STORAGE_SYM MEMORY_SYM {Lex->create_info.storage_media= HA_SM_MEMORY;} | CONNECTION_SYM opt_equal TEXT_STRING_sys { Lex->create_info.connect_string.str= $3.str; Lex->create_info.connect_string.length= $3.length; Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION; } | KEY_BLOCK_SIZE opt_equal ulong_num { @@ -4690,6 +4690,7 @@ alter: lex->alter_info.reset(); lex->alter_info.flags= 0; lex->no_write_to_binlog= 0; + lex->create_info.storage_media= HA_SM_DEFAULT; } alter_commands {} @@ -8342,6 +8343,7 @@ show_param: if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0)) YYABORT; lex->only_view= 0; + lex->create_info.storage_media= HA_SM_DEFAULT; } | CREATE VIEW_SYM table_ident { From f55af1eadeb838ed082f5ab2b7ca75d42ffb3535 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 20 Dec 2006 15:15:26 +0100 Subject: [PATCH 33/40] ndb_dd_ddl.test, ndb_dd_ddl.result, ha_ndbcluster.cc: bug#24667 After ALTER TABLE operation ndb_dd table becomes regular ndb: disallowed TABLESPACE declaration for STORAGE MEMORY Makefile: Rename: storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile -> storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile mgmapi_logevent2.cpp: Rename: storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp -> storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent2.cpp Makefile: Rename mgmapi_logevent_dual to mgmapi_logevent2 mgmapi_logevent2.cpp: Rename: storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent2.cpp -> storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp --- mysql-test/r/ndb_dd_ddl.result | 5 +++++ mysql-test/t/ndb_dd_ddl.test | 9 +++++++++ sql/ha_ndbcluster.cc | 10 ++++++++++ storage/ndb/ndbapi-examples/Makefile | 2 +- .../Makefile | 2 +- .../mgmapi_logevent2.cpp} | 0 6 files changed, 26 insertions(+), 2 deletions(-) rename storage/ndb/ndbapi-examples/{mgmapi_logevent_dual => mgmapi_logevent2}/Makefile (95%) rename storage/ndb/ndbapi-examples/{mgmapi_logevent_dual/mgmapi_logevent_dual.cpp => mgmapi_logevent2/mgmapi_logevent2.cpp} (100%) diff --git a/mysql-test/r/ndb_dd_ddl.result b/mysql-test/r/ndb_dd_ddl.result index eea80090768..56119dc5005 100644 --- a/mysql-test/r/ndb_dd_ddl.result +++ b/mysql-test/r/ndb_dd_ddl.result @@ -183,6 +183,11 @@ INITIAL_SIZE 1M ENGINE NDB; CREATE TABLE t1 (pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE MEMORY +ENGINE NDB; +ERROR HY000: Can't create table 'test.t1' (errno: 138) +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) TABLESPACE ts1 STORAGE DISK ENGINE NDB; CREATE INDEX b_i on t1(b); diff --git a/mysql-test/t/ndb_dd_ddl.test b/mysql-test/t/ndb_dd_ddl.test index 1a470d52c6c..aa692385b07 100644 --- a/mysql-test/t/ndb_dd_ddl.test +++ b/mysql-test/t/ndb_dd_ddl.test @@ -270,11 +270,18 @@ ADD DATAFILE 'datafile2.dat' INITIAL_SIZE 1M ENGINE NDB; +--error 1005 +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE MEMORY +ENGINE NDB; + CREATE TABLE t1 (pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) TABLESPACE ts1 STORAGE DISK ENGINE NDB; + CREATE INDEX b_i on t1(b); CREATE INDEX bc_i on t1(b, c); @@ -351,4 +358,6 @@ engine ndb; drop table t1; + + # End 5.1 test diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f83589dd758..a606d7f77d0 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4836,6 +4836,16 @@ int ha_ndbcluster::create(const char *name, } else if (info->tablespace) { + if (info->storage_media == HA_SM_MEMORY) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ILLEGAL_HA_CREATE_OPTION, + ER(ER_ILLEGAL_HA_CREATE_OPTION), + ndbcluster_hton_name, + "TABLESPACE currently only supported for " + "STORAGE DISK"); + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } tab.setTablespace(info->tablespace); info->storage_media = HA_SM_DISK; //if use tablespace, that also means store on disk } diff --git a/storage/ndb/ndbapi-examples/Makefile b/storage/ndb/ndbapi-examples/Makefile index 2a77cb20afe..6a48afccb48 100644 --- a/storage/ndb/ndbapi-examples/Makefile +++ b/storage/ndb/ndbapi-examples/Makefile @@ -7,7 +7,7 @@ BIN_DIRS := ndbapi_simple \ ndbapi_scan \ mgmapi_logevent \ ndbapi_simple_dual \ - mgmapi_logevent_dual + mgmapi_logevent2 bins: $(patsubst %, _bins_%, $(BIN_DIRS)) diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile similarity index 95% rename from storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile rename to storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile index 4a80a9fe087..95b43b11f6b 100644 --- a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile +++ b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile @@ -1,4 +1,4 @@ -TARGET = mgmapi_logevent_dual +TARGET = mgmapi_logevent2 SRCS = $(TARGET).cpp OBJS = $(TARGET).o CXX = g++ diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp similarity index 100% rename from storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp rename to storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp From dd2c9ea102257030997964f4307cc2686566f7ed Mon Sep 17 00:00:00 2001 From: "tomas@poseidon." <> Date: Wed, 20 Dec 2006 15:34:45 +0100 Subject: [PATCH 34/40] Bug #21806: wrong ndb binlog behaviour when cluster disconnects/restarts - latest gci is reinitialized to 0 at reconnect, ndb binlog thread needs to wait until valid gci is retrieved --- mysql-test/r/ndb_binlog_discover.result | 2 +- mysql-test/t/disabled.def | 4 ++-- sql/ha_ndbcluster_binlog.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ndb_binlog_discover.result b/mysql-test/r/ndb_binlog_discover.result index e81d5cfc6f3..4806047a016 100644 --- a/mysql-test/r/ndb_binlog_discover.result +++ b/mysql-test/r/ndb_binlog_discover.result @@ -5,7 +5,7 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Table_map # # table_id: # (mysql.apply_status) +master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 179ccef475d..b514eaf654f 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -32,8 +32,8 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open #ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events -ndb_binlog_discover : bug#21806 2006-08-24 -ndb_autodiscover3 : bug#21806 +#ndb_binlog_discover : bug#21806 2006-08-24 +#ndb_autodiscover3 : bug#21806 flush2 : Bug#24805 Pushbuild can't handle test with --disable-log-bin diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 7e966497ed0..5598f6c9649 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -3542,7 +3542,7 @@ restart: if (abort_loop) goto err; schema_res= s_ndb->pollEvents(100, &schema_gci); - } while (ndb_latest_received_binlog_epoch == schema_gci); + } while (schema_gci == 0 || ndb_latest_received_binlog_epoch == schema_gci); if (ndb_binlog_running) { Uint64 gci= i_ndb->getLatestGCI(); From 168c5f1424157246bfc047f18dcb09585e659613 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Dec 2006 18:53:25 +0100 Subject: [PATCH 35/40] Fix valgrind warning from deinitializing ha_ndbcluster, referencing another handler from 'plugin_foreach' --- sql/sql_plugin.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 8cd4c661fb8..bdd74d5d80e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -804,6 +804,7 @@ void plugin_shutdown(void) struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, struct st_plugin_int *); plugin_deinitialize(tmp); + plugin_del(tmp); } From 7e7a0e95d33de1935ad7cef654dd428945c9ae0d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Dec 2006 22:57:23 +0100 Subject: [PATCH 36/40] Improve ndb thread shutdown handling --- sql/ha_ndbcluster.cc | 39 ++++++++++++++++++++++++--- sql/ha_ndbcluster_binlog.cc | 53 ++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 34 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index fb091664e93..035d9ae69cd 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -134,7 +134,6 @@ static uint ndbcluster_alter_table_flags(uint flags) } static int ndbcluster_inited= 0; -int ndbcluster_util_inited= 0; static Ndb* g_ndb= NULL; Ndb_cluster_connection* g_ndb_cluster_connection= NULL; @@ -158,6 +157,7 @@ static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *, // Util thread variables pthread_t ndb_util_thread; +int ndb_util_thread_running= 0; pthread_mutex_t LOCK_ndb_util_thread; pthread_cond_t COND_ndb_util_thread; pthread_handler_t ndb_util_thread_func(void *arg); @@ -6720,6 +6720,12 @@ static int ndbcluster_init(void *p) goto ndbcluster_init_error; } + /* Wait for the util thread to start */ + pthread_mutex_lock(&LOCK_ndb_util_thread); + while (!ndb_util_thread_running) + pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread); + pthread_mutex_unlock(&LOCK_ndb_util_thread); + ndbcluster_inited= 1; DBUG_RETURN(FALSE); @@ -6742,6 +6748,27 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) if (!ndbcluster_inited) DBUG_RETURN(0); + ndbcluster_inited= 0; + + /* wait for util thread to finish */ + pthread_mutex_lock(&LOCK_ndb_util_thread); + if (ndb_util_thread_running > 0) + { + pthread_cond_signal(&COND_ndb_util_thread); + pthread_mutex_unlock(&LOCK_ndb_util_thread); + + pthread_mutex_lock(&LOCK_ndb_util_thread); + while (ndb_util_thread_running > 0) + { + struct timespec abstime; + set_timespec(abstime, 1); + pthread_cond_timedwait(&COND_ndb_util_thread, + &LOCK_ndb_util_thread, + &abstime); + } + } + pthread_mutex_unlock(&LOCK_ndb_util_thread); + #ifdef HAVE_NDB_BINLOG { @@ -6788,7 +6815,6 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); - ndbcluster_inited= 0; DBUG_RETURN(0); } @@ -8334,6 +8360,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) { thd->cleanup(); delete thd; + ndb_util_thread_running= 0; DBUG_RETURN(NULL); } thd->init_for_queries(); @@ -8346,6 +8373,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) thd->main_security_ctx.priv_user = 0; thd->current_stmt_binlog_row_based= TRUE; // If in mixed mode + ndb_util_thread_running= 1; + pthread_cond_signal(&COND_ndb_util_thread); + /* wait for mysql server to start */ @@ -8354,8 +8384,6 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) pthread_cond_wait(&COND_server_started, &LOCK_server_started); pthread_mutex_unlock(&LOCK_server_started); - ndbcluster_util_inited= 1; - /* Wait for cluster to start */ @@ -8537,6 +8565,9 @@ ndb_util_thread_end: net_end(&thd->net); thd->cleanup(); delete thd; + pthread_mutex_lock(&LOCK_ndb_util_thread); + ndb_util_thread_running= 0; + pthread_mutex_unlock(&LOCK_ndb_util_thread); DBUG_PRINT("exit", ("ndb_util_thread")); my_thread_end(); pthread_exit(0); diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 7e966497ed0..9ad44c54f52 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -81,6 +81,8 @@ THD *injector_thd= 0; static Ndb *injector_ndb= 0; static Ndb *schema_ndb= 0; +static int ndbcluster_binlog_inited= 0; + /* Mutex and condition used for interacting between client sql thread and injector thread @@ -558,29 +560,28 @@ ndbcluster_binlog_log_query(handlerton *hton, THD *thd, enum_binlog_command binl DBUG_VOID_RETURN; } + /* - End use of the NDB Cluster table handler - - free all global variables allocated by - ndbcluster_init() + End use of the NDB Cluster binlog + - wait for binlog thread to shutdown */ static int ndbcluster_binlog_end(THD *thd) { - DBUG_ENTER("ndb_binlog_end"); + DBUG_ENTER("ndbcluster_binlog_end"); - if (!ndbcluster_util_inited) + if (!ndbcluster_binlog_inited) DBUG_RETURN(0); - - // Kill ndb utility thread - (void) pthread_mutex_lock(&LOCK_ndb_util_thread); - DBUG_PRINT("exit",("killing ndb util thread: %lx", ndb_util_thread)); - (void) pthread_cond_signal(&COND_ndb_util_thread); - (void) pthread_mutex_unlock(&LOCK_ndb_util_thread); + ndbcluster_binlog_inited= 0; #ifdef HAVE_NDB_BINLOG /* wait for injector thread to finish */ + pthread_mutex_lock(&injector_mutex); if (ndb_binlog_thread_running > 0) { + pthread_cond_signal(&injector_cond); + pthread_mutex_unlock(&injector_mutex); + pthread_mutex_lock(&injector_mutex); while (ndb_binlog_thread_running > 0) { @@ -588,8 +589,9 @@ static int ndbcluster_binlog_end(THD *thd) set_timespec(abstime, 1); pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime); } - pthread_mutex_unlock(&injector_mutex); } + pthread_mutex_unlock(&injector_mutex); + /* remove all shares */ { @@ -617,8 +619,10 @@ static int ndbcluster_binlog_end(THD *thd) } pthread_mutex_unlock(&ndbcluster_mutex); } + + pthread_mutex_destroy(&injector_mutex); + pthread_cond_destroy(&injector_cond); #endif - ndbcluster_util_inited= 0; DBUG_RETURN(0); } @@ -2286,31 +2290,21 @@ int ndbcluster_binlog_start() DBUG_RETURN(-1); } - /* - Wait for the ndb injector thread to finish starting up. - */ + ndbcluster_binlog_inited= 1; + + /* Wait for the injector thread to start */ pthread_mutex_lock(&injector_mutex); while (!ndb_binlog_thread_running) pthread_cond_wait(&injector_cond, &injector_mutex); pthread_mutex_unlock(&injector_mutex); - + if (ndb_binlog_thread_running < 0) DBUG_RETURN(-1); + DBUG_RETURN(0); } -static void ndbcluster_binlog_close_connection(THD *thd) -{ - DBUG_ENTER("ndbcluster_binlog_close_connection"); - const char *save_info= thd->proc_info; - thd->proc_info= "ndbcluster_binlog_close_connection"; - do_ndbcluster_binlog_close_connection= BCCC_exit; - while (ndb_binlog_thread_running > 0) - sleep(1); - thd->proc_info= save_info; - DBUG_VOID_RETURN; -} /************************************************************** Internal helper functions for creating/dropping ndb events @@ -3953,6 +3947,7 @@ restart: goto restart; } err: + sql_print_information("Stopping Cluster Binlog"); DBUG_PRINT("info",("Shutting down cluster binlog thread")); thd->proc_info= "Shutting down"; close_thread_tables(thd); @@ -3965,8 +3960,6 @@ err: pthread_mutex_unlock(&injector_mutex); thd->db= 0; // as not to try to free memory - sql_print_information("Stopping Cluster Binlog"); - if (ndb_apply_status_share) { free_share(&ndb_apply_status_share); From fe89182899db9f5e143c206e954942ec09086d0d Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Thu, 21 Dec 2006 16:43:11 +0100 Subject: [PATCH 37/40] Add call to 'thd::clean_up' before deleting THD --- sql/ha_ndbcluster_binlog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 6b56e0d758e..731c0d97cfe 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -4015,8 +4015,8 @@ err: hash_free(&ndb_schema_objects); - // Placed here to avoid a memory leak; TODO: check if needed net_end(&thd->net); + thd->cleanup(); delete thd; ndb_binlog_thread_running= -1; From abe43135b16fb0cbb2aa8e5fff05660bc11dbb7f Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 12:12:58 +0100 Subject: [PATCH 38/40] Bug#22694 "function plugin_foreach_with_mask() uses an uninitialized pointer" Fix uninitialized memory. --- sql/sql_plugin.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 8cd4c661fb8..9ff88b2054a 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -951,29 +951,30 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, state_mask= ~state_mask; // do it only once rw_rdlock(&THR_LOCK_plugin); + total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements + : plugin_hash[type].records; + /* + Do the alloca out here in case we do have a working alloca: + leaving the nested stack frame invalidates alloca allocation. + */ + plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins)); if (type == MYSQL_ANY_PLUGIN) { - total=plugin_array.elements; - plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins)); for (idx= 0; idx < total; idx++) { plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); - if (plugin->state & state_mask) - continue; - plugins[idx]= plugin; + plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL; } } else { - HASH *hash= &plugin_hash[type]; - total=hash->records; - plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins)); + HASH *hash= plugin_hash + type; for (idx= 0; idx < total; idx++) { plugin= (struct st_plugin_int *) hash_element(hash, idx); if (plugin->state & state_mask) continue; - plugins[idx]= plugin; + plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL; } } rw_unlock(&THR_LOCK_plugin); From eb7500f44a964af5370c09d5eb68f1b84a32faba Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 12:14:12 +0100 Subject: [PATCH 39/40] Cset exclude: msvensson@neptunus.(none)|ChangeSet|20061220175325|03033 --- sql/sql_plugin.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index bdd74d5d80e..8cd4c661fb8 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -804,7 +804,6 @@ void plugin_shutdown(void) struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, struct st_plugin_int *); plugin_deinitialize(tmp); - plugin_del(tmp); } From fa3397125230917f22f6a268398957d6ce179789 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 12:27:26 +0100 Subject: [PATCH 40/40] Potential use of NULL pointer in 'plugin_for_each_with_mask', check pointer before referencing it. --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9ff88b2054a..0b203002dec 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -985,7 +985,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, { rw_rdlock(&THR_LOCK_plugin); for (uint i=idx; i < total; i++) - if (plugins[i]->state & state_mask) + if (plugins[i] && plugins[i]->state & state_mask) plugins[i]=0; rw_unlock(&THR_LOCK_plugin); }