Question
· Apr 29

WorkMgr execution issues

Hello Community,

I have a queue that I need to traverse and perform operations on. To distribute the workload across multiple processes, I used a Work Queue Manager do process and I'm not expecting any status from it So, I skipped Sync / WaitForComplete in my implementation

When I execute the below code. Lot of queues are not processed properly. If I add a 0.1-second delay, it works as expected. Is there a minimum time required for a process to start after it's added to the Queue

ClassMethod CleanUpQWrkMgr()
{
    Set QueueId=""
    Set workMgr = ##class(%SYSTEM.WorkMgr).%New()
    If workMgr="" quit
    for {
        Set QueueId = $O(^Q(QueueId),1,data),event="" q:QueueId=""
        Do workMgr.Queue("..Cleanup",QueueId)
        //h .1	
    }
    //Set st= workMgr.WaitForComplete()
}

ClassMethod Cleanup(QueueId As %Integer)
{
    Set event=""
    For {
            Set event = $Order(^Q(QueueId,event)),rev="" Q:event=""
            For {
                Set rev = $Order(^Q(QueueId,event,rev)) Q:rev=""
                If '$Data(^DQ(rev,"e",event))
                Do $I(CNT)
            }
    }
    Set ^test("CNT",QueueId)=CNT
    Quit 1
}

Thanks!

Product version: IRIS 2024.1
$ZV: IRIS for Windows (x86-64) 2024.1.1 (Build 347U) Thu Jul 18 2024 17:40:10 EDT
Discussion (4)2
Log in or sign up to continue

Normally it is required that you call the Sync/WaitForCompelete method on the work queue object so that the module can report errors and you can introduce a sync point where you know that the work done by the worker tasks has completed.

If you do not call Sync/WaitForComplete then what is likely happening if your work queue oref is going out of scope at the end of your procedure which closes the oref and this terminates all work units in this work queue group so if they have not completed at this point they will never get run as the entire queue is removed.