From 31b9145ab3de8813a10937f0894d3e127e78533c Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Mar 2007 00:46:19 +0300 Subject: [PATCH 01/13] sql_insert.cc: Removed wrong fix for the bug#27006. The bug was added by the fix for the bug#19978 and fixed by Monty on 2007/02/21. trigger.test, trigger.result: Corrected test case for the bug#27006. --- mysql-test/r/trigger.result | 11 ++++++----- mysql-test/t/trigger.test | 6 +++--- sql/sql_insert.cc | 10 +++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index da72973dc52..0a0be41927a 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1398,18 +1398,19 @@ id val 1 test1 2 test2 INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); -INSERT INTO t1 VALUES (3,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); SELECT * FROM t1; id val 1 test1 -2 test2 -3 test3 +2 test3 +3 test4 SELECT * FROM t2; id val 1 test1 2 test2 -3 test2 -4 test3 +3 test3 +4 test4 DROP TRIGGER trg27006_a_insert; DROP TRIGGER trg27006_a_update; drop table t1,t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 49b7b527bd9..a01efba11db 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1700,8 +1700,7 @@ DROP PROCEDURE bug22580_proc_1; DROP PROCEDURE bug22580_proc_2; # -# Bug#27006: AFTER UPDATE triggers not fired with INSERT ... ON DUPLICATE KEY -# UPDATE if the row wasn't actually changed. +# Bug#27006: AFTER UPDATE triggers not fired with INSERT ... ON DUPLICATE # --disable_warnings DROP TRIGGER IF EXISTS trg27006_a_update; @@ -1730,7 +1729,8 @@ INSERT INTO t1(val) VALUES ('test1'),('test2'); SELECT * FROM t1; SELECT * FROM t2; INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); -INSERT INTO t1 VALUES (3,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); SELECT * FROM t1; SELECT * FROM t2; DROP TRIGGER trg27006_a_insert; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index dd08ccef462..d9d32d14321 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1238,19 +1238,19 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (table->next_number_field) table->file->adjust_next_insert_id_after_explicit_value( table->next_number_field->val_int()); - info->touched++; + if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || compare_record(table, thd->query_id)) { info->updated++; + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, + TRUE)); info->copied++; } - trg_error= (table->triggers && - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, - TRG_ACTION_AFTER, - TRUE)); goto ok_or_after_trg_err; } else /* DUP_REPLACE */ From 41c732493e290213f7c078ff47553f092218cc51 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Mar 2007 01:37:33 +0300 Subject: [PATCH 02/13] sql_insert.cc: After merge fix. --- sql/sql_insert.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 242ae16a5d3..adb5c34fd37 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1262,26 +1262,22 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) compare_record(table)) { info->updated++; + /* + If ON DUP KEY UPDATE updates a row instead of inserting one, it's + like a regular UPDATE statement: it should not affect the value of a + next SELECT LAST_INSERT_ID() or mysql_insert_id(). + Except if LAST_INSERT_ID(#) was in the INSERT query, which is + handled separately by THD::arg_of_last_insert_id_function. + */ + insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0; + if (table->next_number_field) + table->file->adjust_next_insert_id_after_explicit_value( + table->next_number_field->val_int()); trg_error= (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, - TRG_ACTION_AFTER, - TRUE)); + TRG_ACTION_AFTER, TRUE)); info->copied++; } - /* - If ON DUP KEY UPDATE updates a row instead of inserting one, it's - like a regular UPDATE statement: it should not affect the value of a - next SELECT LAST_INSERT_ID() or mysql_insert_id(). - Except if LAST_INSERT_ID(#) was in the INSERT query, which is - handled separately by THD::arg_of_last_insert_id_function. - */ - insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0; - if (table->next_number_field) - table->file->adjust_next_insert_id_after_explicit_value( - table->next_number_field->val_int()); - trg_error= (table->triggers && - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, - TRG_ACTION_AFTER, TRUE)); goto ok_or_after_trg_err; } From 64b9bda21f23b8e01cdb470d4f6b94e6f83471ab Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Tue, 20 Mar 2007 11:11:08 +0100 Subject: [PATCH 03/13] BUG#24363 If the table structure has been changed, the default action about the restore will fail. - correction of patch, original patch will segfault for print option --- storage/ndb/tools/restore/consumer_restore.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index 7e3395c36f6..2ea79a2aa6c 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -668,7 +668,11 @@ err: } bool -BackupRestore::table_equal(const TableS &tableS){ +BackupRestore::table_equal(const TableS &tableS) +{ + if (!m_restore) + return true; + const char *tablename = tableS.getTableName(); if(tableS.m_dictTable == NULL){ From 7898079378dd39b5d2f2a9343c32b76dd5929f4b Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 20 Mar 2007 16:08:39 +0100 Subject: [PATCH 04/13] ndb - bug#27291 Fix correct min-value for LockPagesInMemory --- ndb/src/mgmsrv/ConfigInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 7f89f5c5c49..7f220c0da65 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -566,7 +566,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { true, ConfigInfo::CI_INT, "0", - "1", + "0", "2" }, { From 844845c7727bde53a63c1d387d343cf06b8c886c Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 20 Mar 2007 16:16:25 +0100 Subject: [PATCH 05/13] ndb - bug#27283 (wl2325-5.0) Handle race condtition between MASTER_GCPCONF and execGCP_NODEFINISH --- ndb/src/kernel/blocks/ERROR_codes.txt | 2 +- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 32 ++++++++++++++-- ndb/test/ndbapi/testNodeRestart.cpp | 45 +++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++ 4 files changed, 79 insertions(+), 4 deletions(-) diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index ed35db91738..9c2b441e7be 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -5,7 +5,7 @@ Next DBACC 3002 Next DBTUP 4014 Next DBLQH 5043 Next DBDICT 6007 -Next DBDIH 7181 +Next DBDIH 7183 Next DBTC 8039 Next CMVMI 9000 Next BACKUP 10022 diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index bf71bc56723..30749cb5a05 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -4811,6 +4811,15 @@ void Dbdih::execMASTER_GCPREQ(Signal* signal) } else { ndbrequire(failedNodePtr.p->nodeStatus == NodeRecord::DYING); }//if + + if (ERROR_INSERTED(7181)) + { + ndbout_c("execGCP_TCFINISHED in MASTER_GCPREQ"); + CLEAR_ERROR_INSERT_VALUE; + signal->theData[1] = coldgcp; + execGCP_TCFINISHED(signal); + } + MasterGCPConf::State gcpState; switch (cgcpParticipantState) { case GCP_PARTICIPANT_READY: @@ -4877,6 +4886,14 @@ void Dbdih::execMASTER_GCPREQ(Signal* signal) masterGCPConf->lcpActive[i] = SYSFILE->lcpActive[i]; sendSignal(newMasterBlockref, GSN_MASTER_GCPCONF, signal, MasterGCPConf::SignalLength, JBB); + + if (ERROR_INSERTED(7182)) + { + ndbout_c("execGCP_TCFINISHED in MASTER_GCPREQ"); + CLEAR_ERROR_INSERT_VALUE; + signal->theData[1] = coldgcp; + execGCP_TCFINISHED(signal); + } }//Dbdih::execMASTER_GCPREQ() void Dbdih::execMASTER_GCPCONF(Signal* signal) @@ -7542,10 +7559,10 @@ void Dbdih::execGCP_NODEFINISH(Signal* signal) } else if (cmasterState == MASTER_TAKE_OVER_GCP) { jam(); //------------------------------------------------------------- - // We are currently taking over as master. We will delay the - // signal until we have completed the take over gcp handling. + // We are currently taking over as master. Ignore + // signal in this case since we will discover it in reception of + // MASTER_GCPCONF. //------------------------------------------------------------- - sendSignalWithDelay(reference(), GSN_GCP_NODEFINISH, signal, 20, 3); return; } else { ndbrequire(cmasterState == MASTER_ACTIVE); @@ -7692,6 +7709,15 @@ void Dbdih::execGCP_TCFINISHED(Signal* signal) Uint32 gci = signal->theData[1]; ndbrequire(gci == coldgcp); + if (ERROR_INSERTED(7181) || ERROR_INSERTED(7182)) + { + ndbout_c("killing %d", refToNode(cmasterdihref)); + signal->theData[0] = 9999; + sendSignal(numberToRef(CMVMI, refToNode(cmasterdihref)), + GSN_NDB_TAMPER, signal, 1, JBB); + return; + } + cgcpParticipantState = GCP_PARTICIPANT_TC_FINISHED; signal->theData[0] = cownNodeId; signal->theData[1] = coldgcp; diff --git a/ndb/test/ndbapi/testNodeRestart.cpp b/ndb/test/ndbapi/testNodeRestart.cpp index e8f8ac66f74..dfb48ea3657 100644 --- a/ndb/test/ndbapi/testNodeRestart.cpp +++ b/ndb/test/ndbapi/testNodeRestart.cpp @@ -1178,6 +1178,48 @@ runBug27003(NDBT_Context* ctx, NDBT_Step* step) } +int +runBug27283(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + int loops = ctx->getNumLoops(); + int records = ctx->getNumRecords(); + NdbRestarter res; + + if (res.getNumDbNodes() < 2) + { + return NDBT_OK; + } + + static const int errnos[] = { 7181, 7182, 0 }; + + Uint32 pos = 0; + for (Uint32 i = 0; i Date: Tue, 20 Mar 2007 17:07:53 +0100 Subject: [PATCH 06/13] enabled test case + some fixes to do the enable --- mysql-test/r/rpl_ndb_sync.result | 8 ++++---- mysql-test/t/disabled.def | 3 --- sql/ha_ndbcluster.cc | 2 ++ sql/ha_ndbcluster_tables.h | 2 ++ storage/ndb/tools/restore/Restore.cpp | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_ndb_sync.result b/mysql-test/r/rpl_ndb_sync.result index 2b9ca24fca0..a2c3b46db5a 100644 --- a/mysql-test/r/rpl_ndb_sync.result +++ b/mysql-test/r/rpl_ndb_sync.result @@ -60,11 +60,11 @@ hex(c2) hex(c3) c1 0 1 BCDEF 1 0 CD 0 0 DEFGHIJKL -SELECT @the_epoch:=MAX(epoch) FROM mysql.apply_status; +SELECT @the_epoch:=MAX(epoch) FROM mysql.ndb_apply_status; @the_epoch:=MAX(epoch) SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1) -FROM mysql.binlog_index WHERE epoch > ORDER BY epoch ASC LIMIT 1; +FROM mysql.ndb_binlog_index WHERE epoch > ORDER BY epoch ASC LIMIT 1; @the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1) master-bin.000001 CHANGE MASTER TO @@ -89,8 +89,8 @@ hex(c2) hex(c3) c1 DROP DATABASE ndbsynctest; STOP SLAVE; reset master; -select * from mysql.binlog_index; +select * from mysql.ndb_binlog_index; Position File epoch inserts updates deletes schemaops reset slave; -select * from mysql.apply_status; +select * from mysql.ndb_apply_status; server_id epoch diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 913fe8e62ee..be3e80dd969 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -16,8 +16,6 @@ concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_load : BUG#17233 2006-05-04 tomas failed load data from infile causes mysqld dbug_assert, binlog not flushed -ndb_restore_partition : Problem with cluster/def/schema table that is in std_data/ndb_backup51; Pekka will schdule this to someone -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 rpl_ndb_2innodb : BUG#19227 2006-04-20 pekka pk delete apparently not replicated @@ -37,5 +35,4 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb plugin : Bug#25659 memory leak via "plugins" test rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly -ndb_alter_table : Bug##25774 ndb_alter_table.test fails in DBUG_ASSERT() on Linux x64 ndb_single_user : Bug#27021 Error codes in mysqld in single user mode varies diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 44df0958c39..ba03d0a54d9 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -7608,7 +7608,9 @@ int handle_trailing_share(NDB_SHARE *share) /* Ndb share has not been released as it should */ +#ifdef NOT_YET DBUG_ASSERT(FALSE); +#endif /* This is probably an error. We can however save the situation diff --git a/sql/ha_ndbcluster_tables.h b/sql/ha_ndbcluster_tables.h index 9f7b9146d91..c6bc8f577f8 100644 --- a/sql/ha_ndbcluster_tables.h +++ b/sql/ha_ndbcluster_tables.h @@ -15,7 +15,9 @@ */ #define NDB_REP_DB "mysql" +#define OLD_NDB_REP_DB "cluster" #define NDB_REP_TABLE "ndb_binlog_index" #define NDB_APPLY_TABLE "ndb_apply_status" #define OLD_NDB_APPLY_TABLE "apply_status" #define NDB_SCHEMA_TABLE "ndb_schema" +#define OLD_NDB_SCHEMA_TABLE "schema" diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp index 3d466384782..6b00d69108d 100644 --- a/storage/ndb/tools/restore/Restore.cpp +++ b/storage/ndb/tools/restore/Restore.cpp @@ -310,7 +310,8 @@ RestoreMetaData::markSysTables() "cluster_replication" -> "cluster" -> "mysql" */ strcmp(tableName, "cluster_replication/def/" OLD_NDB_APPLY_TABLE) == 0 || - strcmp(tableName, "cluster/def/" OLD_NDB_APPLY_TABLE) == 0 || + strcmp(tableName, OLD_NDB_REP_DB "/def/" OLD_NDB_APPLY_TABLE) == 0 || + strcmp(tableName, OLD_NDB_REP_DB "/def/" OLD_NDB_SCHEMA_TABLE) == 0 || strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) == 0 || strcmp(tableName, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE)== 0 ) table->isSysTable = true; From ffb35b80fe1d845da85bd48b54df03023b4d241a Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 08:02:11 +0100 Subject: [PATCH 07/13] minor fix of ndb cluster startup script --- mysql-test/ndb/ndbcluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index 1e25cd8047e..2d550294c84 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -35,8 +35,8 @@ if [ -d ../sql ] ; then exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd exec_waiter=$ndbtop/tools/ndb_waiter exec_test=$ndbtop/tools/ndb_test_platform - exec_test_ndberror= exec_test_ndberror=$ndbtop/src/ndbapi/ndberror_check + exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm else BINARY_DIST=1 if test -x "$BASEDIR/libexec/ndbd" From 3ab996f18fcdfd6afcdc2b3cf8371ef13d73478e Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 08:22:36 +0100 Subject: [PATCH 08/13] correct event buffer status reporting --- storage/ndb/src/common/debugger/EventLogger.cpp | 4 ++-- storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/storage/ndb/src/common/debugger/EventLogger.cpp b/storage/ndb/src/common/debugger/EventLogger.cpp index f6665faa187..6e446646898 100644 --- a/storage/ndb/src/common/debugger/EventLogger.cpp +++ b/storage/ndb/src/common/debugger/EventLogger.cpp @@ -652,9 +652,9 @@ void getTextEventBufferStatus(QQQQ) { "Event buffer status: used=%d%s(%d%) alloc=%d%s(%d%) " "max=%d%s apply_gci=%lld latest_gci=%lld", used, used_unit, - theData[2] ? (theData[1]*100)/theData[2] : 0, + theData[2] ? (Uint32)((((Uint64)theData[1])*100)/theData[2]) : 0, alloc, alloc_unit, - theData[3] ? (theData[2]*100)/theData[3] : 0, + theData[3] ? (Uint32)((((Uint64)theData[2])*100)/theData[3]) : 0, max_, max_unit, theData[4]+(((Uint64)theData[5])<<32), theData[6]+(((Uint64)theData[7])<<32)); diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 828ba51bc21..3449f3ff1d2 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -2100,15 +2100,17 @@ NdbEventBuffer::alloc_mem(EventBufData* data, NdbMem_Free((char*)data->memory); assert(m_total_alloc >= data->sz); - m_total_alloc -= data->sz; data->memory = 0; data->sz = 0; data->memory = (Uint32*)NdbMem_Allocate(alloc_size); if (data->memory == 0) + { + m_total_alloc -= data->sz; DBUG_RETURN(-1); + } data->sz = alloc_size; - m_total_alloc += data->sz; + m_total_alloc += add_sz; if (change_sz != NULL) *change_sz += add_sz; @@ -2780,7 +2782,7 @@ NdbEventBuffer::reportStatus() else apply_gci= latest_gci; - if (100*m_free_data_sz < m_min_free_thresh*m_total_alloc && + if (100*(Uint64)m_free_data_sz < m_min_free_thresh*(Uint64)m_total_alloc && m_total_alloc > 1024*1024) { /* report less free buffer than m_free_thresh, @@ -2791,7 +2793,7 @@ NdbEventBuffer::reportStatus() goto send_report; } - if (100*m_free_data_sz > m_max_free_thresh*m_total_alloc && + if (100*(Uint64)m_free_data_sz > m_max_free_thresh*(Uint64)m_total_alloc && m_total_alloc > 1024*1024) { /* report more free than 2 * m_free_thresh From 5682efdfcf455deadaf5b6c144e598366e0ea004 Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 08:40:24 +0100 Subject: [PATCH 09/13] Bug #26825 MySQL Server Crashes in high load - initialize to NULL, to avoid call of free on uninitialized variable --- sql/ha_ndbcluster.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 3d0d8a3f079..877005039e2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -952,7 +952,7 @@ int ha_ndbcluster::get_metadata(const char *path) DBUG_PRINT("enter", ("m_tabname: %s, path: %s", m_tabname, path)); do { - const void *data, *pack_data; + const void *data= NULL, *pack_data= NULL; uint length, pack_length; if (!(tab= dict->getTable(m_tabname))) @@ -3755,7 +3755,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) if ((my_errno= build_index_list(ndb, table, ILBP_OPEN))) DBUG_RETURN(my_errno); - const void *data, *pack_data; + const void *data= NULL, *pack_data= NULL; uint length, pack_length; if (readfrm(table->s->path, &data, &length) || packfrm(data, length, &pack_data, &pack_length) || @@ -4343,7 +4343,7 @@ int ha_ndbcluster::create(const char *name, NDBTAB tab; NDBCOL col; uint pack_length, length, i, pk_length= 0; - const void *data, *pack_data; + const void *data= NULL, *pack_data= NULL; char name2[FN_HEADLEN]; bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE); @@ -4378,8 +4378,11 @@ int ha_ndbcluster::create(const char *name, if (readfrm(name, &data, &length)) DBUG_RETURN(1); if (packfrm(data, length, &pack_data, &pack_length)) + { + my_free((char*)data, MYF(0)); DBUG_RETURN(2); - + } + DBUG_PRINT("info", ("setFrm data: 0x%lx len: %d", (long) pack_data, pack_length)); tab.setFrm(pack_data, pack_length); my_free((char*)data, MYF(0)); From ec97b008f014db16d4b0e90dfd690c95f4c5da39 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 08:47:54 +0100 Subject: [PATCH 10/13] ndb - bug#27286 make sure master node is sendable, when getting ref::NotMaster --- storage/ndb/src/mgmsrv/MgmtSrvr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp index f46ee8261ec..34f4927f804 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2131,6 +2131,8 @@ MgmtSrvr::alloc_node_id_req(NodeId free_node_id, enum ndb_mgm_node_type type) { do_send = 1; nodeId = refToNode(ref->masterRef); + if (!theFacade->get_node_alive(nodeId)) + nodeId = 0; continue; } return ref->errorCode; @@ -2621,6 +2623,8 @@ MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted) ndbout_c("I'm not master resending to %d", nodeId); #endif do_send = 1; // try again + if (!theFacade->get_node_alive(nodeId)) + m_master_node = nodeId = 0; continue; } event.Event = BackupEvent::BackupFailedToStart; From 7834bd584615f41b1c9eeec07d2c1f58dcf37536 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 08:57:14 +0100 Subject: [PATCH 11/13] ndb - bug#27286 (5.0 version) make sure master is sendable --- ndb/src/mgmsrv/MgmtSrvr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 5c4a5ef7d17..cad299e5386 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2406,6 +2406,8 @@ MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted) ndbout_c("I'm not master resending to %d", nodeId); #endif do_send = 1; // try again + if (!theFacade->get_node_alive(nodeId)) + m_master_node = nodeId = 0; continue; } event.Event = BackupEvent::BackupFailedToStart; From 585782e0847f322b9167642e9beae04c8cbff958 Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 09:23:49 +0100 Subject: [PATCH 12/13] Bug #26825 MySQL Server Crashes in high load - initialize to NULL, to avoid call of free on uninitialized variable --- sql/ha_ndbcluster.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index b091ad10fd3..ab7c3e2edc8 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6063,7 +6063,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, int error= 0; NdbError ndb_error; uint len; - const void* data; + const void* data= NULL; Ndb* ndb; char key[FN_REFLEN]; DBUG_ENTER("ndbcluster_discover"); @@ -6131,6 +6131,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, DBUG_RETURN(0); err: + my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); if (share) free_share(&share); if (ndb_error.code) From b950160a467000340d7a3a55abcc8e6a3c35081d Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Wed, 21 Mar 2007 15:34:47 +0100 Subject: [PATCH 13/13] ndb - bug#27283 Additional fix for 2-node case --- ndb/src/kernel/blocks/dbdih/Dbdih.hpp | 2 ++ ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 7 ++++++- ndb/src/kernel/blocks/dbtc/Dbtc.hpp | 3 +++ ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index 41240a2d620..97c123ae3f4 100644 --- a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -1628,6 +1628,8 @@ private: // NR Uint32 c_dictLockSlavePtrI_nodeRestart; // userPtr for NR void recvDictLockConf_nodeRestart(Signal* signal, Uint32 data, Uint32 ret); + + Uint32 c_error_7181_ref; }; #if (DIH_CDATA_SIZE < _SYSFILE_SIZE32) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 30749cb5a05..967c00ea50f 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -4816,6 +4816,7 @@ void Dbdih::execMASTER_GCPREQ(Signal* signal) { ndbout_c("execGCP_TCFINISHED in MASTER_GCPREQ"); CLEAR_ERROR_INSERT_VALUE; + signal->theData[0] = c_error_7181_ref; signal->theData[1] = coldgcp; execGCP_TCFINISHED(signal); } @@ -4891,6 +4892,7 @@ void Dbdih::execMASTER_GCPREQ(Signal* signal) { ndbout_c("execGCP_TCFINISHED in MASTER_GCPREQ"); CLEAR_ERROR_INSERT_VALUE; + signal->theData[0] = c_error_7181_ref; signal->theData[1] = coldgcp; execGCP_TCFINISHED(signal); } @@ -7697,6 +7699,7 @@ void Dbdih::execGCP_COMMIT(Signal* signal) cgckptflag = false; emptyverificbuffer(signal, true); cgcpParticipantState = GCP_PARTICIPANT_COMMIT_RECEIVED; + signal->theData[0] = calcDihBlockRef(masterNodeId); signal->theData[1] = coldgcp; sendSignal(clocaltcblockref, GSN_GCP_NOMORETRANS, signal, 2, JBB); return; @@ -7706,11 +7709,13 @@ void Dbdih::execGCP_TCFINISHED(Signal* signal) { jamEntry(); CRASH_INSERTION(7007); + Uint32 retRef = signal->theData[0]; Uint32 gci = signal->theData[1]; ndbrequire(gci == coldgcp); if (ERROR_INSERTED(7181) || ERROR_INSERTED(7182)) { + c_error_7181_ref = retRef; // Save ref ndbout_c("killing %d", refToNode(cmasterdihref)); signal->theData[0] = 9999; sendSignal(numberToRef(CMVMI, refToNode(cmasterdihref)), @@ -7722,7 +7727,7 @@ void Dbdih::execGCP_TCFINISHED(Signal* signal) signal->theData[0] = cownNodeId; signal->theData[1] = coldgcp; signal->theData[2] = cfailurenr; - sendSignal(cmasterdihref, GSN_GCP_NODEFINISH, signal, 3, JBB); + sendSignal(retRef, GSN_GCP_NODEFINISH, signal, 3, JBB); }//Dbdih::execGCP_TCFINISHED() /*****************************************************************************/ diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index 792586d7baf..1e8fcee759c 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -1952,5 +1952,8 @@ private: // those variables should be removed and exchanged for stack // variable communication. /**************************************************************************/ + + Uint32 c_gcp_ref; }; + #endif diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 9f1426109d4..1185b790bdd 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -6894,6 +6894,7 @@ void Dbtc::timeOutFoundFragLab(Signal* signal, UintR TscanConPtr) void Dbtc::execGCP_NOMORETRANS(Signal* signal) { jamEntry(); + c_gcp_ref = signal->theData[0]; tcheckGcpId = signal->theData[1]; if (cfirstgcp != RNIL) { jam(); @@ -9937,6 +9938,7 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { void Dbtc::gcpTcfinished(Signal* signal) { + signal->theData[0] = c_gcp_ref; signal->theData[1] = tcheckGcpId; sendSignal(cdihblockref, GSN_GCP_TCFINISHED, signal, 2, JBB); }//Dbtc::gcpTcfinished()