cancel
Showing results for 
Search instead for 
Did you mean: 

Transaction - single thread

Former Member
0 Kudos

Hi

I have a MII transaction that I would like to ensure that it run in semaphore mode (i.e this transaction has only 1 thread at one time).

Since this transaction will be triggered interval every 10secs from Scheduler and at the same time once a while triggered from another transaction, I would like to ensure the 2nd thread will not get run. I thought of using Shared memory to save the running thread's status in which the second thread will prove it before executing its actions. But this solution is not prefered.

Anyone has any idea?

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I appreciate if anyone has such requirement and would share the possible solution

thanks

olivier_thiry
Participant
0 Kudos

We also had those kind of requirement... We did what you suggested : using a shared memory flag, checking it at start of transaction, and setting it back to false at end of transaction or if the last run (kept also in shared memory) is greater than 2 times the normal delay between 2 runs...

But we are open to other stronger way to achieve this...

Former Member
0 Kudos

Hi Olivier

If your transaction is solely triggered from Scheduler, you do not need to implement such mechanism. The scheduler knows that the previous transaction has to be ended before new thread being executed.

olivier_thiry
Participant
0 Kudos

Hi,

In theory yes, but the scheduler is buggy, and sometimes starts the transaction several times... We opened an OSS note, but no result and we don't really expect to get quick answer, that's why we implemented this flag...

Former Member
0 Kudos

Hi,

There is another way I came through during a recent implementation.

This method uses transaction ID to stop the transaction from executing in a parallel thread.

Logic::

  1. Create a shared variable name it oldTransactionId with -1 as its default value.

2. Check if (Persistent.oldTransactionId < 0) and (Persistent.oldTransactionId < transactionid) , If true, its a new transaction .. go ahead process it.

     2.1 ..  Set the transactionid to the oldTransactionId shared property. The trasnactionId can be retrieved by using the keyword 'transactionid' in assignment action block.

      2.2..       The last step of the transaction should be to set the oldTransactionId to -1 to ensure the execution happens in next try.

3. If false, then

      3.1..  stop the transaction from executing. Because the older one is still running.

I have attached the snapshot of my sample trx, pause action is just to simulate longer duration.

Though it is very similar to the flag implementation, this method gives better visibility about which transaction is still running and which one is trying to access.

Thanks and Regards,

Tufale Ashai.

olivier_thiry
Participant
0 Kudos

Thanks Tufale, nice way to achieve this also. In fact, in our case, the job can not run more than once in a period of 15 minutes, but must run normally every hour, as it feeds a production system the guys on the shop floor needs to produce.

That's why we have this extra test on last run, so if it's more than 45 minutes, we allow the job to run anyway, to avoid to have to do any manual update of the shared memory flag (important in a 24/7 system )