List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:November 8 2010 9:38am
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3342)
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:jonas@stripped

 3342 Ole John Aske	2010-11-08
      spj-svs: Corrected a potential mutex issue accessing 'm_finalBatchFrags' within ::nextRootResult)
      
      m_finalBatchFrags requires the PullGuard mutex to be locked before accesing it. However, in 
      ::nextRootResult() it was accessed wo/ mutex.
      
      Moved the mutex violating logic inside :awaitMoreResults() where the mutex is locked,
      and extended the return values from ::awaitMoreResults() to include 
      'FetchResult_noMoreCache'.

    modified:
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp
=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-11-05 14:45:27 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-11-08 09:38:33 +0000
@@ -1713,17 +1713,19 @@ NdbQueryImpl::nextRootResult(bool fetchA
         assert (m_error.code == 0);
         assert (m_applFrags.getCurrent()==NULL);
         getRoot().nullifyResult();
-        if (!fetchAllowed)
-        {
-          return NdbQuery::NextResult_bufferEmpty;
-        }
-        else if (m_finalBatchFrags == getRootFragCount())
+        m_state = EndOfData;
+        postFetchRelease();
+        return NdbQuery::NextResult_scanComplete;
+
+      case FetchResult_noMoreCache: // No cached data, no error
+        assert (m_error.code == 0);
+        assert (m_applFrags.getCurrent()==NULL);
+        getRoot().nullifyResult();
+        if (fetchAllowed)
         {
-          m_state = EndOfData;
-          postFetchRelease();
-          return NdbQuery::NextResult_scanComplete;
+          break;  // ::sendFetchMore() may request more results
         }
-        break;  // ::sendFetchMore() will request more results
+        return NdbQuery::NextResult_bufferEmpty;
 
       case FetchResult_gotError:    // Error in 'm_error.code'
         assert (m_error.code != 0);
@@ -1823,7 +1825,8 @@ NdbQueryImpl::awaitMoreResults(bool forc
         if (m_pendingFrags == 0)
         {
           // 'No more *pending* results', ::sendFetchMore() may make more available
-          return FetchResult_noMoreData;
+          return (m_finalBatchFrags < getRootFragCount()) ? FetchResult_noMoreCache 
+                                                          : FetchResult_noMoreData;
         }
 
         /* More results are on the way, so we wait for them.*/
@@ -1873,6 +1876,7 @@ NdbQueryImpl::awaitMoreResults(bool forc
        *  - There was no matching row for an inner join.
        *  - or, the application called nextResult() twice for a lookup query.
        */
+      assert(m_finalBatchFrags == getRootFragCount());
       return FetchResult_noMoreData;
     }
     else

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp	2010-11-05 14:45:27 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp	2010-11-08 09:38:33 +0000
@@ -199,8 +199,9 @@ public:
   { return m_rootFragCount; }
 
 private:
-  /** Possible return values from NdbQueryImpl::awaitMoreResults. Integer values
-   * matches those returned from PoolGuard::wait_scan().
+  /** Possible return values from NdbQueryImpl::awaitMoreResults. 
+   * A subset of the integer values also matches those returned
+   * from PoolGuard::wait_scan().
    */
   enum FetchResult{
     FetchResult_gotError = -4,  // There is an error avail in 'm_error.code'
@@ -208,7 +209,8 @@ private:
     FetchResult_nodeFail = -2,
     FetchResult_timeOut = -1,
     FetchResult_ok = 0,
-    FetchResult_noMoreData = 1
+    FetchResult_noMoreData = 1,
+    FetchResult_noMoreCache = 2
   };
 
   /** A stack of NdbRootFragment pointers.


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20101108093833-bf0qh8yqksrnmcvj.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3342) Ole John Aske8 Nov