From: Jan Wedvik Date: June 16 2011 9:18am Subject: bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (jan.wedvik:3503 to 3505) List-Archive: http://lists.mysql.com/commits/139298 Message-Id: <20110616091819.DC21F224@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3505 Jan Wedvik 2011-06-16 This commit is a regression test case mysql-5.1-telco-7.0 revno: 4457, which was: "There was an error in the code setting the T_SCAN_REPEATABLE flag. The flag was set on the parent of the intended operation rather than on the operation itself. This caused scan ranges for the repeatable scan to be released too early. This gave wrong results when running a bushy scan where the scan to be repeated used pruning." modified: mysql-test/suite/ndb/r/ndb_join_pushdown.result mysql-test/suite/ndb/t/ndb_join_pushdown.test 3504 Jan Wedvik 2011-06-16 [merge] Merged from mysql-5.1-telco-7.0. modified: mysql-test/suite/ndb/r/ndb_join_pushdown.result storage/ndb/include/mgmapi/mgmapi_config_parameters.h storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp storage/ndb/src/mgmsrv/ConfigInfo.cpp storage/ndb/src/ndbapi/ndberror.c 3503 Ole John Aske 2011-06-15 [merge] merge from telco-7.0 -> spj-scan-scan modified: mysql-test/suite/ndb_rpl/my.cnf mysql-test/suite/ndb_rpl/t/ndb_rpl_break_3_chain.cnf mysql-test/suite/ndb_rpl/t/ndb_rpl_multi_binlog_update.cnf mysql-test/suite/ndb_team/my.cnf mysql-test/suite/rpl_ndb/my.cnf sql/ha_ndbcluster.cc sql/ha_ndbcluster.h sql/sql_class.cc sql/sql_class.h storage/ndb/src/common/portlib/CMakeLists.txt storage/ndb/src/common/util/ndbzio.c storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp storage/ndb/src/kernel/vm/NdbSeqLock.hpp storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp storage/ndb/src/ndbapi/ndberror.c storage/ndb/test/ndbapi/testSystemRestart.cpp storage/ndb/test/run-test/autotest-boot.sh storage/ndb/test/src/NdbBackup.cpp === modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result' --- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2011-06-07 12:26:02 +0000 +++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2011-06-16 09:17:41 +0000 @@ -2070,7 +2070,27 @@ join t1 as t2 on t2.a = t1.c join t1 as t3 on t3.a = t1.c; count(*) 208 +CREATE TABLE tx ( +a int NOT NULL, +PRIMARY KEY (`a`) +); +delete from t1; +insert into tx values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +insert into t1 select 1, x1.a * 10+x2.a, 1, 0 from tx as x1 cross join tx as x2; +explain select count(*) from t1 as x1 +join t1 as x2 on x2.a = x1.c and x1.b < 2 +join t1 as x3 on x3.a = x1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE x1 ALL NULL NULL NULL NULL 100 Parent of 3 pushed join@1; Using where with pushed condition +1 SIMPLE x2 ref PRIMARY PRIMARY 4 test.x1.c 1 Child of 'x1' in pushed join@1 +1 SIMPLE x3 ref PRIMARY PRIMARY 4 test.x1.c 1 Child of 'x1' in pushed join@1 +select count(*) from t1 as x1 +join t1 as x2 on x2.a = x1.c and x1.b < 2 +join t1 as x3 on x3.a = x1.c; +count(*) +20000 drop table t1; +drop table tx; create table t1 (a int, b int, primary key(a) using hash) engine = ndb; insert into t1 values (1, 2); insert into t1 values (2, 3); @@ -5169,13 +5189,13 @@ and spj_counts_at_end.counter_name <> 'L and spj_counts_at_end.counter_name <> 'SCAN_BATCHES_RETURNED'; counter_name spj_counts_at_end.val - spj_counts_at_startup.val CONST_PRUNED_RANGE_SCANS_RECEIVED 6 -LOCAL_TABLE_SCANS_SENT 234 -PRUNED_RANGE_SCANS_RECEIVED 21 +LOCAL_TABLE_SCANS_SENT 236 +PRUNED_RANGE_SCANS_RECEIVED 25 RANGE_SCANS_RECEIVED 720 READS_NOT_FOUND 6616 READS_RECEIVED 52 -SCAN_ROWS_RETURNED 94353 -TABLE_SCANS_RECEIVED 234 +SCAN_ROWS_RETURNED 95391 +TABLE_SCANS_RECEIVED 236 select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT' from spj_counts_at_end, spj_counts_at_startup where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name @@ -5186,15 +5206,15 @@ LOCAL+REMOTE READS_SENT drop table spj_counts_at_startup; drop table spj_counts_at_end; scan_count -2562 +2565 pruned_scan_count 8 sorted_scan_count 10 pushed_queries_defined -381 +383 pushed_queries_dropped 11 pushed_queries_executed -533 +534 set ndb_join_pushdown = @save_ndb_join_pushdown; === modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test' --- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2011-06-07 12:26:02 +0000 +++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2011-06-16 09:17:41 +0000 @@ -1007,8 +1007,28 @@ select count(*) from t1 join t1 as t2 on t2.a = t1.c join t1 as t3 on t3.a = t1.c; -drop table t1; +# Test bushy join with pruned scan and larger result set. + +CREATE TABLE tx ( + a int NOT NULL, + PRIMARY KEY (`a`) +); + +delete from t1; +insert into tx values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); + +insert into t1 select 1, x1.a * 10+x2.a, 1, 0 from tx as x1 cross join tx as x2; + +explain select count(*) from t1 as x1 + join t1 as x2 on x2.a = x1.c and x1.b < 2 + join t1 as x3 on x3.a = x1.c; +select count(*) from t1 as x1 + join t1 as x2 on x2.a = x1.c and x1.b < 2 + join t1 as x3 on x3.a = x1.c; + +drop table t1; +drop table tx; # pushed mrr does not yet handle multiple PK operations in same transaction # Need 6.0 result handling stuff to simplify result handling === modified file 'storage/ndb/include/mgmapi/mgmapi_config_parameters.h' --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h 2011-05-31 08:28:58 +0000 +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h 2011-06-15 10:55:06 +0000 @@ -194,6 +194,8 @@ #define CFG_DB_INDEX_STAT_TRIGGER_SCALE 625 #define CFG_DB_INDEX_STAT_UPDATE_DELAY 626 +#define CFG_DB_MAX_DML_OPERATIONS_PER_TRANSACTION 627 + #define CFG_NODE_ARBIT_RANK 200 #define CFG_NODE_ARBIT_DELAY 201 #define CFG_RESERVED_SEND_BUFFER_MEMORY 202 === modified file 'storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp' --- a/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp 2011-06-07 12:08:29 +0000 +++ b/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp 2011-06-16 08:37:10 +0000 @@ -4418,7 +4418,7 @@ Dbspj::scanIndex_build(Build_context& ct if (requestPtr.p->m_bits & Request::RT_REPEAT_SCAN_RESULT && !treeNodePtr.p->m_ancestors.contains(ctx.m_scans)) { - nodePtr.p->m_bits |= TreeNode::T_SCAN_REPEATABLE; + treeNodePtr.p->m_bits |= TreeNode::T_SCAN_REPEATABLE; } ctx.m_scan_cnt++; @@ -5025,6 +5025,8 @@ Dbspj::scanIndex_parent_batch_repeat(Sig DEBUG("scanIndex_parent_batch_repeat(), m_node_no: " << treeNodePtr.p->m_node_no << ", m_batch_chunks: " << data.m_batch_chunks); + + ndbassert(treeNodePtr.p->m_bits & TreeNode::T_SCAN_REPEATABLE); /** * Register index-scans to be restarted if we didn't get all === modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp' --- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp 2011-05-26 15:04:45 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp 2011-06-16 09:00:55 +0000 @@ -140,6 +140,7 @@ #define ZUNLOCKED_IVAL_TOO_HIGH 294 #define ZUNLOCKED_OP_HAS_BAD_STATE 295 #define ZBAD_DIST_KEY 298 +#define ZTRANS_TOO_BIG 261 #endif class Dbtc: public SimulatedBlock { @@ -722,6 +723,7 @@ public: }; Uint32 no_commit_ack_markers; + Uint32 m_write_count; ReturnSignal returnsignal; AbortState abortState; @@ -2102,6 +2104,7 @@ private: Uint32 c_lastFailedApi; #endif Uint32 m_deferred_enabled; + Uint32 m_max_writes_per_trans; }; #endif === modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp' --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp 2011-04-28 07:47:53 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp 2011-06-15 10:55:06 +0000 @@ -338,6 +338,7 @@ Dbtc::Dbtc(Block_context& ctx, Uint32 in c_apiConTimer_line = 0; csystemStart = SSS_FALSE; m_deferred_enabled = ~Uint32(0); + m_max_writes_per_trans = ~Uint32(0); }//Dbtc::Dbtc() Dbtc::~Dbtc() === modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp' --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-06-07 12:19:47 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2011-06-16 09:00:55 +0000 @@ -685,6 +685,10 @@ void Dbtc::execREAD_CONFIG_REQ(Signal* s //ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_TRANSACTION_TAKEOVER, &val); set_no_parallel_takeover(val); + val = ~(Uint32)0; + ndb_mgm_get_int_parameter(p, CFG_DB_MAX_DML_OPERATIONS_PER_TRANSACTION, &val); + m_max_writes_per_trans = val; + ctimeOutCheckDelay = 50; // 500ms }//Dbtc::execSIZEALT_REP() @@ -1857,6 +1861,13 @@ start_failure: abortErrorLab(signal); return; } + case 65: + { + jam(); + terrorCode = ZTRANS_TOO_BIG; + abortErrorLab(signal); + return; + } default: jam(); systemErrorLab(signal, __LINE__); @@ -2398,6 +2409,8 @@ void Dbtc::initApiConnectRec(Signal* sig #ifdef ERROR_INSERT regApiPtr->continueBCount = 0; #endif + + regApiPtr->m_write_count = 0; }//Dbtc::initApiConnectRec() int @@ -3068,6 +3081,11 @@ void Dbtc::execTCKEYREQ(Signal* signal) case ZWRITE: case ZREFRESH: jam(); + if (unlikely((++ regApiPtr->m_write_count) > m_max_writes_per_trans)) + { + TCKEY_abort(signal, 65); + return; + } break; default: TCKEY_abort(signal, 9); === modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp' --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2011-05-19 09:16:32 +0000 +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2011-06-15 10:55:06 +0000 @@ -36,6 +36,7 @@ #define KEY_INTERNAL 0 #define MAX_INT_RNIL 0xfffffeff +#define MAX_INT32 0xffffffff #define MAX_PORT_NO 65535 #define _STR_VALUE(x) #x @@ -771,6 +772,19 @@ const ConfigInfo::ParamInfo ConfigInfo:: STR_VALUE(MAX_INT_RNIL) }, { + CFG_DB_MAX_DML_OPERATIONS_PER_TRANSACTION, + "MaxDMLOperationsPerTransaction", + DB_TOKEN, + "Max DML-operations in one transaction (0 == no limit)", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + STR_VALUE(MAX_INT32), + "32", + STR_VALUE(MAX_INT32) + }, + + { CFG_DB_NO_LOCAL_OPS, "MaxNoOfLocalOperations", DB_TOKEN, === modified file 'storage/ndb/src/ndbapi/ndberror.c' --- a/storage/ndb/src/ndbapi/ndberror.c 2011-06-15 10:40:26 +0000 +++ b/storage/ndb/src/ndbapi/ndberror.c 2011-06-16 09:00:55 +0000 @@ -317,6 +317,8 @@ ErrorBundle ErrorCodes[] = { */ { 281, HA_ERR_NO_CONNECTION, AE, "Operation not allowed due to cluster shutdown in progress" }, { 299, DMEC, AE, "Operation not allowed or aborted due to single user mode" }, + { 261, DMEC, AE, + "DML count in transaction exceeds config parameter MaxDMLOperationsPerTransaction" }, { 763, DMEC, AE, "DDL is not supported with mixed data-node versions" }, { 823, DMEC, AE, "Too much attrinfo from application in tuple manager" }, { 829, DMEC, AE, "Corrupt data received for insert/update" }, No bundle (reason: useless for push emails).