Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

gh-1832 Fix Deleting a workunit should remove from queues #2041

Merged
merged 1 commit into from

2 participants

@afishbeck
Collaborator

This addresses an external users issue. This shouldn't happen unless
the workunit state is no longer active, but it is somehow stuck in
the queue.

To test, one can simulate the issue by stopping the cluster, queueing
a workunit, setting the state to failed, then deleting the workunit.

Fixes gh-1832.

Signed-off-by: Anthony Fishbeck Anthony.Fishbeck@lexisnexis.com

@afishbeck afishbeck gh-1832 Fix Deleting a workunit should remove from queues
This addresses an external users issue.  This shouldn't happen unless
the workunit state is no longer active, but it is somehow stuck in
the queue.

To test, one can simulate the issue by stopping the cluster, queueing
a workunit, setting the state to failed, then deleting the workunit.

Fixes gh-1832.
Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>
1215015
@richardkchapman richardkchapman merged commit 84b170e into hpcc-systems:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2012
  1. @afishbeck

    gh-1832 Fix Deleting a workunit should remove from queues

    afishbeck authored
    This addresses an external users issue.  This shouldn't happen unless
    the workunit state is no longer active, but it is somehow stuck in
    the queue.
    
    To test, one can simulate the issue by stopping the cluster, queueing
    a workunit, setting the state to failed, then deleting the workunit.
    
    Fixes gh-1832.
    Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>
This page is out of date. Refresh to see the latest.
View
1  common/workunit/workunit.cpp
@@ -1960,6 +1960,7 @@ class CWorkUnitFactory : public CInterface, implements IWorkUnitFactory, impleme
}
else
cw->cleanupAndDelete(true,true);
+ removeWorkUnitFromAllQueues(wuid); //known active workunits wouldn't make it this far
return true;
}
View
27 common/workunit/wujobq.cpp
@@ -1897,6 +1897,33 @@ extern bool WORKUNIT_API runWorkUnit(const char *wuid)
return false;
}
+extern WORKUNIT_API StringBuffer &getQueuesContainingWorkUnit(const char *wuid, StringBuffer &queueList)
+{
+ Owned<IRemoteConnection> conn = querySDS().connect("/JobQueues", myProcessSession(), RTM_LOCK_READ, 5000);
+ if (!conn)
+ return queueList;
+
+ VStringBuffer xpath("Queue[Item/@wuid='%s']", wuid);
+ Owned<IPropertyTreeIterator> it = conn->getElements(xpath.str());
+ ForEach(*it)
+ {
+ if (queueList.length())
+ queueList.append(',');
+ queueList.append(it->query().queryProp("@name"));
+ }
+ return queueList;
+}
+
+extern void WORKUNIT_API removeWorkUnitFromAllQueues(const char *wuid)
+{
+ StringBuffer queueList;
+ if (!getQueuesContainingWorkUnit(wuid, queueList).length())
+ return;
+ Owned<IJobQueue> q = createJobQueue(queueList.str());
+ if (q)
+ while(q->remove(wuid));
+}
+
extern bool WORKUNIT_API switchWorkUnitQueue(IWorkUnit* wu, const char *cluster)
{
if (!wu)
View
2  common/workunit/wujobq.hpp
@@ -139,6 +139,8 @@ extern WORKUNIT_API IJobQueue *createJobQueue(const char *name);
extern bool WORKUNIT_API runWorkUnit(const char *wuid, const char *cluster);
extern bool WORKUNIT_API runWorkUnit(const char *wuid);
+extern WORKUNIT_API StringBuffer & getQueuesContainingWorkUnit(const char *wuid, StringBuffer &queueList);
+extern WORKUNIT_API void removeWorkUnitFromAllQueues(const char *wuid);
extern bool WORKUNIT_API switchWorkUnitQueue(IWorkUnit* wu, const char *cluster);
Something went wrong with that request. Please try again.