Browse Source

HPCC-14678 Check/abort WU when WUSyntaxCheck times out

When ESP performs an ECL syntax check using WUSyntaxCheck, it
submits a workunit. If that workunit takes greater than the
timeout period (default 60 seconds), the existing code tries
to delete the workunit. The workunit deletion may fail if the
workunit is still in a submitted state. In this fix, the code
is added to check the workunit state. If the state is allowed,
deleteWorkUnit() will be called. If not, call secAbortWorkUnit()
then deleteWorkUnit().

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 9 years ago
parent
commit
47ac79a912
2 changed files with 24 additions and 2 deletions
  1. 1 0
      esp/scm/ws_workunits.ecm
  2. 23 2
      esp/services/ws_workunits/ws_workunitsService.cpp

+ 1 - 0
esp/scm/ws_workunits.ecm

@@ -1021,6 +1021,7 @@ ESPrequest WUSyntaxCheckRequest
 ESPresponse [exceptions_inline] WUSyntaxCheckResponse
 {
     ESParray<ESPstruct ECLException> Errors;
+    [min_ver("1.57")] string Message;
 };
 
 

+ 23 - 2
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -1124,10 +1124,31 @@ bool CWsWorkunitsEx::onWUSyntaxCheckECL(IEspContext &context, IEspWUSyntaxCheckR
         Owned<IConstWorkUnit> cw(factory->openWorkUnit(wuid.str()));
         WsWUExceptions errors(*cw);
         resp.setErrors(errors);
+
+        StringBuffer msg;
+        WUState st = cw->getState();
         cw.clear();
 
-        if (!factory->deleteWorkUnit(wuid.str()))
-            throw MakeStringException(ECLWATCH_CANNOT_DELETE_WORKUNIT, "%s: Workunit cannot be deleted. Please check ESP log.", wuid.str());
+        switch (st)
+        {
+        case WUStateAborted:
+        case WUStateCompleted:
+        case WUStateFailed:
+            if (!factory->deleteWorkUnit(wuid.str()))
+                throw MakeStringException(ECLWATCH_CANNOT_DELETE_WORKUNIT, "Workunit %s cannot be deleted.", wuid.str());
+            break;
+        default:
+            secAbortWorkUnit(wuid.str(), *context.querySecManager(), *context.queryUser());
+            if (!factory->deleteWorkUnit(wuid.str()))
+            {
+                throw MakeStringException(ECLWATCH_CANNOT_DELETE_WORKUNIT,
+                    "WUSyntaxCheckECL has timed out. Workunit %s cannot be deleted now. You may delete it when its status changes.", wuid.str());
+            }
+            if (context.getClientVersion() < 1.57)
+                throw MakeStringException(ECLWATCH_CANNOT_DELETE_WORKUNIT, "WUSyntaxCheckECL has timed out.");
+            resp.setMessage("WUSyntaxCheckECL has timed out.");
+            break;
+        }
     }
     catch(IException* e)
     {