浏览代码

HPCC-10683 Fix WU connection leak in WsWorkunits and a warning in ESP log

When a new job is submitted, WsWorkunit creates connections to
dali to get information about the WU. Due to a bug, one of the
connections is not released. The same problem also occurs when
a ZAP Report is created. The bug is fixed here.

The WsWorkunits::WUUpdate method is used when a user wants to
modify a wu. The last step of the method is to retrieve/send
back the updated information about the WU. The information
includes possible thor log files for the WU. The WUUpdate method
is also called when a new job is submitted. A Warning line "
WARNING: Cannot find TargetClusterInfo for workunit ..." is
written to esp log when the method trys to retrieve thor log
information. This is because the WU is just created and no
cluster has been specified for the WU yet. This fix skips the
warning code if no cluster has been specified for a WU.
Kevin Wang 11 年之前
父节点
当前提交
7f93586183

+ 4 - 4
common/workunit/workunit.cpp

@@ -640,7 +640,7 @@ public:
     virtual unsigned __int64 getHash() const;
     virtual IStringIterator *getLogs(const char *type, const char *component) const;
     virtual IStringIterator *getProcesses(const char *type) const;
-    virtual IPropertyTreeIterator& getProcesses(const char *type, const char *instance) const;
+    virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const;
 
     virtual bool getWuDate(unsigned & year, unsigned & month, unsigned& day);
     virtual IStringVal & getSnapshot(IStringVal & str) const;
@@ -1103,7 +1103,7 @@ public:
             { return c->getLogs(type, instance); }
     virtual IStringIterator *getProcesses(const char *type) const
             { return c->getProcesses(type); }
-    virtual IPropertyTreeIterator& getProcesses(const char *type, const char *instance) const
+    virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const
             { return c->getProcesses(type, instance); }
 
     virtual void clearExceptions()
@@ -5232,7 +5232,7 @@ IStringIterator *CLocalWorkUnit::getLogs(const char *type, const char *instance)
         return new CStringPTreeAttrIterator(p->getElements(xpath.str()), "@log");
 }
 
-IPropertyTreeIterator& CLocalWorkUnit::getProcesses(const char *type, const char *instance) const
+IPropertyTreeIterator* CLocalWorkUnit::getProcesses(const char *type, const char *instance) const
 {
     VStringBuffer xpath("Process/%s/", type);
     if (instance)
@@ -5240,7 +5240,7 @@ IPropertyTreeIterator& CLocalWorkUnit::getProcesses(const char *type, const char
     else
         xpath.append("*");
     CriticalBlock block(crit);
-    return * p->getElements(xpath.str());
+    return p->getElements(xpath.str());
 }
 
 IStringIterator *CLocalWorkUnit::getProcesses(const char *type) const

+ 1 - 1
common/workunit/workunit.hpp

@@ -925,7 +925,7 @@ interface IConstWorkUnit : extends IInterface
     virtual unsigned __int64 getHash() const = 0;
     virtual IStringIterator *getLogs(const char *type, const char *instance=NULL) const = 0;
     virtual IStringIterator *getProcesses(const char *type) const = 0;
-    virtual IPropertyTreeIterator& getProcesses(const char *type, const char *instance) const = 0;
+    virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const = 0;
 };
 
 

+ 12 - 7
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -512,11 +512,12 @@ void WsWuInfo::getHelpers(IEspECLWorkunit &info, unsigned flags)
 
         if (cw->getWuidVersion() > 0)
         {
-            IPropertyTreeIterator& eclAgents = cw->getProcesses("EclAgent", NULL);
-            ForEach (eclAgents)
+            Owned<IPropertyTreeIterator> eclAgents = cw->getProcesses("EclAgent", NULL);
+            ForEach (*eclAgents)
             {
-                StringBuffer logName, agentPID;
-                eclAgents.query().getProp("@log",logName);
+                StringBuffer logName;
+                IPropertyTree& eclAgent = eclAgents->query();
+                eclAgent.getProp("@log",logName);
                 if (!logName.length())
                     continue;
 
@@ -530,8 +531,8 @@ void WsWuInfo::getHelpers(IEspECLWorkunit &info, unsigned flags)
                         h->setFileSize(fileSize);
                     if (version >= 1.44)
                     {
-                        if (eclAgents.query().hasProp("@pid"))
-                            h->setPID(eclAgents.query().getPropInt("@pid"));
+                        if (eclAgent.hasProp("@pid"))
+                            h->setPID(eclAgent.getPropInt("@pid"));
                         else
                             h->setPID(cw->getAgentPID());
                     }
@@ -940,7 +941,11 @@ unsigned WsWuInfo::getWorkunitThorLogInfo(IArrayOf<IEspECLHelpFile>& helpers, IE
     if (cw->getWuidVersion() > 0)
     {
         SCMStringBuffer clusterName;
-        Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(cw->getClusterName(clusterName).str());
+        cw->getClusterName(clusterName);
+        if (!clusterName.length()) //Cluster name may not be set yet
+            return countThorLog;
+
+        Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(clusterName.str());
         if (!clusterInfo)
         {
             SCMStringBuffer wuid;

+ 5 - 4
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -3898,15 +3898,16 @@ bool CWsWorkunitsEx::onWUDeployWorkunit(IEspContext &context, IEspWUDeployWorkun
 
 void CWsWorkunitsEx::addProcessLogfile(IZZIPor* zipper, Owned<IConstWorkUnit> &cwu, WsWuInfo &winfo, const char * process, PointerArray &mbArr)
 {
-    IPropertyTreeIterator& proc = cwu->getProcesses(process, NULL);
-    ForEach (proc)
+    Owned<IPropertyTreeIterator> procs = cwu->getProcesses(process, NULL);
+    ForEach (*procs)
     {
         StringBuffer logSpec;
-        proc.query().getProp("@log",logSpec);
+        IPropertyTree& proc = procs->query();
+        proc.getProp("@log",logSpec);
         if (!logSpec.length())
             continue;
         StringBuffer pid;
-        pid.appendf("%d",proc.query().getPropInt("@pid"));
+        pid.appendf("%d",proc.getPropInt("@pid"));
         MemoryBuffer * pMB = NULL;
         try
         {