Run Process - How to Determine When All Completed.

chewza
Posts: 147
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Run Process - How to Determine When All Completed.

Post by chewza »

Hi there

I am having the same issue you mentioned that someone put in a previous posts as per below. I am also finding this a bit of a show-stopper. Does anyone have any ideas of how to get around this?

Many thx!

Regards
Chris


The biggest problem with this new command is there is no way to know when all of them are done so that you can do the next sequential action. For example, after 12 months are loaded, how do you then kick of an allocation script, or a email saying everything is fine. You have to end up jumping through some synchronization hoops (i.e. updating a cube) to get this all to work properly. What happens when one fails? How do you stop subsequent processes based on a condition? How do you control the size of the queue to keep it within CPU limits? etc. etc.

In my opinion, it really isn't any better than TM1RunTI, other than it taking up a single connection.

We ended up having to write our own external command lines to really do what you need to for parallel processing. Hopefully IBM will add other control functions to make this truly usable outside of simplistic use cases.
JohnO
Posts: 96
Joined: Mon Jul 29, 2019 5:02 am
OLAP Product: Planning Analytics
Version: 2.0.9.x
Excel Version: Office 365 16

Re: Run Process - How to Determine When All Completed.

Post by JohnO »

The answer is that there are no simple answers. The only orchestration tool within the standard product is cognos command center and it won't explicty help you with this.

For queue management there is a technique using synchronized function. Described in a cubewise article from memory. Lets say you have 4 cores you can use but 20 runprocess to issue. You can issue all 20 run process commands and limit the synchronized paramter to 4 different names across the 20. That way you will only have 4 running at a time. Should work fine if the duration of each is close to the average.

How do we know when it finishes? In the above scenario it is a matter of determing when there is nothing remaining of the 4.. My experience is that the TI calling runprocess may finish yet the called processes may still be running. I resorted to flag files to determine when the overall procees could be considered finished. Basically you need to stop the calling process from finishing until all runprocess are finished. A few o/s call and loops etc and asssumptions about how long you should wait.

My biggest problem with run process was locking, both between these processes and with other processes. I found that my biggest problem was everything becoming serial. So rather than say 20 processes running in 4 minutes it would all go back to 80 minutes.

Lots of challenges. There is a fundamental lack of orchestration across TI's and runprocess is an extra set of challenges with that.
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Run Process - How to Determine When All Completed.

Post by Steve Rowe »

As JohnO said the only way I know to do this is counting Flag files. Something like this.

Main Job
Clear your Flag folder of all files.

Figure out how many RunProcess calls you are are going to make = nFlagCount

Call all your Run Process jobs

Loop Until FlagCount>=nFlagCount
FlagCount is the sum of count of the files in the Flag Folder plus any new TM1ProcessError files for the Run Process Job. Use WildCardFileSearch plus Sleep.

Call any further jobs as required.
For bonues point process Flag files to update record keeping
End Main Job

RunProcess Job
In the epilog write out your Flag file. I actually put a load of record keeping in here, start / finish time, row counts, error count etc
End RunProcess Job

For locking your RunProcess job should not include any object creation (cubes, dimensions, elements, views and sets), watch out if you are using Asciiouput that you make sure the file names are unique (add the thread ID).

There maybe some use cases where creating objects in the parallel piece is OK but I just find it easier to avoid it entirely.

HTH
Technical Director
www.infocat.co.uk
JohnO
Posts: 96
Joined: Mon Jul 29, 2019 5:02 am
OLAP Product: Planning Analytics
Version: 2.0.9.x
Excel Version: Office 365 16

Re: Run Process - How to Determine When All Completed.

Post by JohnO »

I just found this relating to the new PA engine:

https://www.ibm.com/docs/en/planning-an ... -analytics

Have a read of the improvements to TI's
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Run Process - How to Determine When All Completed.

Post by Steve Rowe »

Nice spot JohnO, looks like they will provided a step change in our ability manage parallel processing.
Technical Director
www.infocat.co.uk
John Hammond
Community Contributor
Posts: 295
Joined: Mon Mar 23, 2009 10:50 am
OLAP Product: PAW/PAX 2.0.72 Perspectives
Version: TM1 Server 11.8.003
Excel Version: 365 and 2016
Location: South London

Re: Run Process - How to Determine When All Completed.

Post by John Hammond »

So the TM1 Servers move to the cloud as a service for IBM managed clouds (Openshift I assume).

This will be the same black boxing as the PAW HTTP and Webservices and mean traditional access to the servers disk objects is gone without admin access to the cloud platform. All good until something breaks.

Developers kind of return to the old MVS/CICS world. It's a big rapid shift.
MarenC
Regular Participant
Posts: 350
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: Run Process - How to Determine When All Completed.

Post by MarenC »

Hi,

I stopped using RunProcess in production because the results were too erratic in development!

As for the new PA server, I think there are some pretty big show stoppers that would prevent many organisations moving to it, though off the top of my head I can't remember what they are?

So I am expecting hell to freeze over before we can utilise those benefits.

Maren
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Run Process - How to Determine When All Completed.

Post by Steve Rowe »

What kind of erraticness were you hitting with RunProcess MarenC?

I've a MT job running hourly that I am not seeing issues with, at least the customer has not raised them to me.
Technical Director
www.infocat.co.uk
MarenC
Regular Participant
Posts: 350
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: Run Process - How to Determine When All Completed.

Post by MarenC »

Hi Steve,

Some issues were described here within the comments thread:

https://www.tm1forum.com/viewtopic.php?t=14841

Given the erratic nature I experienced, I basically gave up on RunProcess as I could have no definite confidence in it.

This is maybe something I will return to, as I know it can save hours of time.

Maren
chewza
Posts: 147
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Re: Run Process - How to Determine When All Completed.

Post by chewza »

Seem to be close to getting this working. (Just need to code/conquer one final part as per below). Used a SQL table to determine when all processes have completed, and thereby control next sequential step

Master Process (using 2 cores to run in parallel as an example)
Prolog:
RUNPROCESS(sProcess, sPara1, 'pLockObj', '1','pBatchNo', 1, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara2, 'pLockObj', '2','pBatchNo', 2, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara3, 'pLockObj', '1','pBatchNo', 3, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara4, 'pLockObj', '2','pBatchNo', 4, 'pBatchNoTotalExpected', 4);

Check out my Slave process further down at this point

Still to complete:
Set something up to query the SQL table to determine when all complete and call the Process to be run after all is complete(what this is all about). Still need to code and test this part, but here is my plan (Anyone got any better ideas for this part?):
H
    • ave While loop running say every 30 seconds for 10 minutes (a maximum amount of time this would take in the worst scenario)
      Call a second slave process that queries SQL table where query only returns a single record for situation where max batchno = BatchNoTotalExpected
      In the data section of this slave process I can then be in a position to execute the process that I want to run once all the RunProcess threads are completed (the goal behind this whole challenge)
      Clear records in flag control process
      Finally now be in situation to call the Ti I need to call after everything has run.
Have while loop to check "Flag_Control_ParallelRun" tble (see below) every (say) 30 seconds
When max batch number in table hits total expected number of batches, you know that everything in complete


Slave Process
Prolog:
IF (pLockObj @<>'');
SYNCHRONIZED (pLockObj);
ENDIF;

Data:
Do Some stuff

Epilog:
Use a sQl server table - e.g. (Flag_Control_ParallelRun)
Have field for batch no and total batch expected (and other useful fields - eg end date)
Insert record in epilog and include batch no and total batch expected
chewza
Posts: 147
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Re: Run Process - How to Determine When All Completed.

Post by chewza »

Seem to be close to getting this working. (Just need to code/conquer one final part as per below). Used a SQL table to determine when all processes have completed, and thereby control next sequential step

Master Process (using 2 cores to run in parallel as an example)
Prolog:
RUNPROCESS(sProcess, sPara1, 'pLockObj', '1','pBatchNo', 1, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara2, 'pLockObj', '2','pBatchNo', 2, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara3, 'pLockObj', '1','pBatchNo', 3, 'pBatchNoTotalExpected', 4);
RUNPROCESS(sProcess, sPara4, 'pLockObj', '2','pBatchNo', 4, 'pBatchNoTotalExpected', 4);

Check out my Slave process further down at this point

Still to complete:
Set something up to query the SQL table to determine when all complete and call the Process to be run after all is complete(what this is all about). Still need to code and test this part, but here is my plan (Anyone got any better ideas for this part?):
H
    • ave aWhile loop running say every 30 seconds for 10 minutes (a maximum amount of time this would take in the worst scenario)
      Call a second slave process that queries SQL table where query only returns a single record for situation where max batchno = BatchNoTotalExpected
      In the data section of this slave process I can then be in a position to execute the process that I want to run once all the RunProcess threads are completed (the goal behind this whole challenge)
      Clear records in flag control process
      Finally now be in situation to call the Ti I need to call after everything has run.
Have while loop to check "Flag_Control_ParallelRun" tble (see below) every (say) 30 seconds
When max batch number in table hits total expected number of batches, you know that everything in complete


Slave Process
Prolog:
IF (pLockObj @<>'');
SYNCHRONIZED (pLockObj);
ENDIF;

Data:
Do Some stuff

Epilog:
Use a sQl server table - e.g. (Flag_Control_ParallelRun)
Have field for batch no and total batch expected (and other useful fields - eg end date)
Insert record in epilog and include batch no and total batch expected
User avatar
PavoGa
MVP
Posts: 617
Joined: Thu Apr 18, 2013 6:59 pm
OLAP Product: TM1
Version: 10.2.2 FP7, PA2.0.9.1
Excel Version: 2013 PAW
Location: Charleston, Tennessee

Re: Run Process - How to Determine When All Completed.

Post by PavoGa »

This can be accomplished with SYNCHRONIZE.

Say you have two groups of processes to execute. The second group should not execute until after the first group has all finished. For each RunProcess of the first group, SYCHRONIZE a distinct object (remember, it is just a token and does not have to be an object in the database) in each call. For example Larry, Curly and Moe are each passed, respectively, to three instances of RunProcess.

Pass Larry:Curly:Moe to a wrapper process of the second group of processes. Parse that parameter value and SYNCHRONIZE Larry, Curly and Moe in succession in that wrapper process. It will not execute its batch of second group processes until locks are released on all three of Larry, Curly and Moe.

I've used a form of this to run up to three batches of processes, each batch needing to complete before the next batch executes. The users are turned loose in a few seconds avoiding looking at a stuck screen while the processes run in the background.
Ty
Cleveland, TN
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Run Process - How to Determine When All Completed.

Post by Wim Gielis »

With RunProcess I observe huge increases in memory.
Also, Synchronized when used in PAW does not seem to make the parent process wait for all child processes to finish.
Not sure if others see this behavior as well ?
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
chewza
Posts: 147
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Re: Run Process - How to Determine When All Completed.

Post by chewza »

Hi Guys

Thanks everyone for you feedback.

Just a question for you. Say for example, the server has 8 cores, and your process has 3 RunProcess commands. So this will utilise 3 cores.
Given your server has 8, this seems like it should not be an issue. However, what if you have a whole lot of chores activate at the same time - e.g. 6 chores kick of within a time span of 3 minutes. Will these try and use a core each, bringing the core count to 9 which exceeds the server maximum?

Not sure if this scenario can play out and if there is a potential risk?
User avatar
PavoGa
MVP
Posts: 617
Joined: Thu Apr 18, 2013 6:59 pm
OLAP Product: TM1
Version: 10.2.2 FP7, PA2.0.9.1
Excel Version: 2013 PAW
Location: Charleston, Tennessee

Re: Run Process - How to Determine When All Completed.

Post by PavoGa »

Wim Gielis wrote: Sun Jun 18, 2023 10:48 pm With RunProcess I observe huge increases in memory.
Also, Synchronized when used in PAW does not seem to make the parent process wait for all child processes to finish.
Not sure if others see this behavior as well ?
I would not expect SYNCHRONIZE to make the parent process wait for the child processes and that behavior is pre-PAW as well. What is the usage context?
Ty
Cleveland, TN
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Run Process - How to Determine When All Completed.

Post by Wim Gielis »

PavoGa wrote: Tue Jun 20, 2023 2:09 pm
Wim Gielis wrote: Sun Jun 18, 2023 10:48 pm With RunProcess I observe huge increases in memory.
Also, Synchronized when used in PAW does not seem to make the parent process wait for all child processes to finish.
Not sure if others see this behavior as well ?
I would not expect SYNCHRONIZE to make the parent process wait for the child processes and that behavior is pre-PAW as well. What is the usage context?
The context is that a user clicks on a button in PAW. It kicks off the mother process.
The mother process should wait for the child processes to finish.
If not, the user sees the toaster message that the fired process is ready (very quickly) yet in fact,
the real is still about to begin in the background...
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
PavoGa
MVP
Posts: 617
Joined: Thu Apr 18, 2013 6:59 pm
OLAP Product: TM1
Version: 10.2.2 FP7, PA2.0.9.1
Excel Version: 2013 PAW
Location: Charleston, Tennessee

Re: Run Process - How to Determine When All Completed.

Post by PavoGa »

Wim Gielis wrote: Tue Jun 20, 2023 3:35 pm
PavoGa wrote: Tue Jun 20, 2023 2:09 pm
Wim Gielis wrote: Sun Jun 18, 2023 10:48 pm With RunProcess I observe huge increases in memory.
Also, Synchronized when used in PAW does not seem to make the parent process wait for all child processes to finish.
Not sure if others see this behavior as well ?
I would not expect SYNCHRONIZE to make the parent process wait for the child processes and that behavior is pre-PAW as well. What is the usage context?
The context is that a user clicks on a button in PAW. It kicks off the mother process.
The mother process should wait for the child processes to finish.
If not, the user sees the toaster message that the fired process is ready (very quickly) yet in fact,
the real is still about to begin in the background...
Yes, but you wouldn't use SYNCHRONIZE for controlling the parent process to wait for the child to finish.
Ty
Cleveland, TN
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Run Process - How to Determine When All Completed.

Post by Wim Gielis »

PavoGa wrote: Tue Jun 20, 2023 4:16 pm
Wim Gielis wrote: Tue Jun 20, 2023 3:35 pm
PavoGa wrote: Tue Jun 20, 2023 2:09 pm

I would not expect SYNCHRONIZE to make the parent process wait for the child processes and that behavior is pre-PAW as well. What is the usage context?
The context is that a user clicks on a button in PAW. It kicks off the mother process.
The mother process should wait for the child processes to finish.
If not, the user sees the toaster message that the fired process is ready (very quickly) yet in fact,
the real is still about to begin in the background...
Yes, but you wouldn't use SYNCHRONIZE for controlling the parent process to wait for the child to finish.
Any other 'easy' method as an alternative ? File semaphores, or other ?
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
PavoGa
MVP
Posts: 617
Joined: Thu Apr 18, 2013 6:59 pm
OLAP Product: TM1
Version: 10.2.2 FP7, PA2.0.9.1
Excel Version: 2013 PAW
Location: Charleston, Tennessee

Re: Run Process - How to Determine When All Completed.

Post by PavoGa »

File semaphores is what I use currently to control a parent process. I believe I read about using adding/removing attributes or elements and tested it a few years back, but never used in production. The file semaphores seem to work well enough.

Wasn't there a post the other day about some additional variables available for use with RunProcess? I searched but have not found it.
Ty
Cleveland, TN
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Run Process - How to Determine When All Completed.

Post by Wim Gielis »

PavoGa wrote: Tue Jun 20, 2023 5:55 pmWasn't there a post the other day about some additional variables available for use with RunProcess? I searched but have not found it.
That doesn't ring a bell unfortunately.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply