瀏覽代碼

Merge pull request #1902 from richardkchapman/roxie-lookupjoin-leak-gh1901

gh-1901 Lookup join leaking rows on failure

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 13 年之前
父節點
當前提交
6c21b59600
共有 3 個文件被更改,包括 38 次插入15 次删除
  1. 24 15
      roxie/ccd/ccdserver.cpp
  2. 3 0
      testing/ecl/roxie/key/lookupfail.xml
  3. 11 0
      testing/ecl/roxie/lookupfail.ecl

+ 24 - 15
roxie/ccd/ccdserver.cpp

@@ -16846,7 +16846,7 @@ private:
                 if(index==size)
                     index = 0;
                 if(index==start)
-                    return; //table is full, should never happen
+                    throwUnexpected(); //table is full, should never happen
             }
             table[index] = right;
         }
@@ -16967,23 +16967,32 @@ public:
     void loadRight()
     {
         ConstPointerArray rightset;
-        const void * next;
-        while(true)
+        unsigned i = 0;
+        try
         {
-            next = input1->nextInGroup();
-            if(!next)
+            const void * next;
+            while(true)
+            {
                 next = input1->nextInGroup();
-            if(!next)
-                break;
-            rightset.append(next);
-        }
-
-        unsigned rightord = rightset.ordinality();
-        table.setown(new LookupTable(rightord, helper.queryCompareLeftRight(), helper.queryCompareRight(), helper.queryHashLeft(), helper.queryHashRight(), dedupRHS));
+                if(!next)
+                    next = input1->nextInGroup();
+                if(!next)
+                    break;
+                rightset.append(next);
+            }
+            unsigned rightord = rightset.ordinality();
+            table.setown(new LookupTable(rightord, helper.queryCompareLeftRight(), helper.queryCompareRight(), helper.queryHashLeft(), helper.queryHashRight(), dedupRHS));
 
-        unsigned i;
-        for(i=0; i<rightord; i++)
-            table->add(rightset.item(i));
+            for(i=0; i<rightord; i++)
+                table->add(rightset.item(i));
+        }
+        catch (...)
+        {
+            unsigned rightord = rightset.ordinality();
+            for ( ; i<rightord; i++)
+                ReleaseRoxieRow(rightset.item(i));
+            throw;
+        }
     };
 
     virtual void reset()

+ 3 - 0
testing/ecl/roxie/key/lookupfail.xml

@@ -0,0 +1,3 @@
+<Dataset name='Result 1'>
+ <Row><f>Success</f></Row>
+</Dataset>

+ 11 - 0
testing/ecl/roxie/lookupfail.ecl

@@ -0,0 +1,11 @@
+d := dataset([{'bad'},{'worse'}], {string f});
+
+d success := transform
+  self.f := 'Success';
+end;
+
+l := NOFOLD(LIMIT(NOFOLD(d), 1));
+
+j := JOIN(d,l,LEFT.f=right.f);
+
+CATCH(j,ONFAIL(success));