List:Commits« Previous MessageNext Message »
From:Jan Wedvik Date:June 7 2011 12:08pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (jan.wedvik:4441)
View as plain text  
#At file:///net/atum17/export/home/tmp/jw159207/mysql/repo/mysql-5.1-telco-7.0/ based on revid:jonas@stripped

 4441 Jan Wedvik	2011-06-07
      This fix only applies to pushed queries (i.e. those using NdbQuery and the SPJ block).
      
      This commit fixes an error related to bushy scans where the right hand side (i.e. the scan that is executed
      several times for genrating a cross product) used pruning. The algoritm for couning how many fragments to scan
      only worked correctly for the first execution. The second execution would typically cause an assert.

    modified:
      storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2011-05-25 09:31:27 +0000
+++ b/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2011-06-07 12:08:29 +0000
@@ -4879,12 +4879,6 @@ Dbspj::scanIndex_parent_row(Signal* sign
     }
 
     Uint32 ptrI = fragPtr.p->m_rangePtrI;
-    if (ptrI == RNIL)
-    {
-      jam();
-      data.m_frags_not_complete++;
-    }
-
     bool hasNull;
     if (treeNodePtr.p->m_bits & TreeNode::T_KEYINFO_CONSTRUCTED)
     {
@@ -4972,6 +4966,39 @@ Dbspj::scanIndex_parent_batch_complete(S
   data.m_rows_received = 0;
   data.m_rows_expecting = 0;
   ndbassert(data.m_frags_outstanding == 0);
+  ndbassert(data.m_frags_not_complete == 0);
+
+  Ptr<ScanFragHandle> fragPtr;
+  {
+    Local_ScanFragHandle_list list(m_scanfraghandle_pool, data.m_fragments);
+    list.first(fragPtr);
+
+    if ((treeNodePtr.p->m_bits & TreeNode::T_PRUNE_PATTERN) == 0)
+    {
+      if (fragPtr.p->m_rangePtrI != RNIL)
+      {
+        // No pruning, so we must scan all fragments.
+        jam();
+        data.m_frags_not_complete = data.m_fragCount;
+      }
+    }
+    else
+    {
+      while(!fragPtr.isNull())
+      {
+        if (fragPtr.p->m_rangePtrI != RNIL)
+        {
+          jam();
+          /**
+           * This is a pruned scan, so we must scan those fragments that
+           * some distribution key hashed to.
+           */
+          data.m_frags_not_complete++;
+        }
+        list.next(fragPtr);
+      }
+    }
+  }
 
   if (data.m_frags_not_complete == 0)
   {
@@ -4981,11 +5008,6 @@ Dbspj::scanIndex_parent_batch_complete(S
      */
     return;
   }
-  else if ((treeNodePtr.p->m_bits & TreeNode::T_PRUNE_PATTERN) == 0)
-  {
-    jam();
-    data.m_frags_not_complete = data.m_fragCount;
-  }
 
   /**
    * When parent's batch is complete, we send our batch
@@ -5014,7 +5036,6 @@ Dbspj::scanIndex_parent_batch_repeat(Sig
     DEBUG("Register TreeNode for restart, m_node_no: " << treeNodePtr.p->m_node_no);
     ndbrequire(treeNodePtr.p->m_state != TreeNode::TN_ACTIVE);
     registerActiveCursor(requestPtr, treeNodePtr);
-    data.m_frags_not_complete = 1;
     data.m_batch_chunks = 0;
   }
 }


Attachment: [text/bzr-bundle] bzr/jan.wedvik@oracle.com-20110607120829-td98eg6givu0nvg7.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jan.wedvik:4441) Jan Wedvik7 Jun