17
Views
4
Comments
Solved
The role of the timeout in unexpected errors
Question

Hi,

In outsystems document, 


https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/OutSystems_Platform_Timers_and_Asynchronous_Processes


>The role of the timeout in unexpected errors

>If the execution of a Timer terminates due to an unexpected error, the Scheduler Service recovers the >Timer and synchronize the database only after the timeout time plus 20% has passed. 

>Until then, the data about Timers in the database may be inconsistent.


>It's also important to implement the login in the Timer action so that you make sure that data is kept >consistent in case of the Timer execution terminates unexpectedly.


I dont understand it, and how to implement the login in the Timer action?


Thank you very much.


mvp_badge
MVP
Rank: #18
Solution

Hi shake mountain,

It has to do with any logging you might be doing in the business logic. If you don't login, any usage of GetUserId() will return NullIdentifier() and you will not be able to immediately determine if the log was generated by regular user that did not login or if it was generated by a timer.

If timers always perform login with the same user (and that user is only used by your timers and internal processes) that means you have a more clear view on what generated logs and can better understand what's going on at any given moment.

Hope this clarifies a bit better what Frederico meant!

Hello Shake,


About your two questions:

1) 

>The role of the timeout in unexpected errors

>If the execution of a Timer terminates due to an unexpected error, the Scheduler Service recovers the >Timer and synchronize the database only after the timeout time plus 20% has passed. 

>Until then, the data about Timers in the database may be inconsistent.


After an execution of the timer is aborted due to an unexpected (uncaught) exception the OutSystems watchdog responsible for operating the timers (the Scheduler Service) may take some time to detect the abnormal termination and update the OutSystems database accordingly (error and next run). This delay is capped to the maximum duration of the timer plus 20%. 

In the most normal case of the default of 20-minute maximum timer execution duration, this implies that after 24 minutes of starting the timer you are guaranteed to have updated information in the OutSystems database (visible in ServiceCenter timer status).


2) 

> and how to implement the login in the Timer action?

If you add references to the system component you will notice that there is a login action that only requires a username. This can be used in timers so that the corresponding business logic runs in the scope of a user, and not as anonymous. 

It's recommended that you create a dedicated administrative (not adminitrator) user for this kind of operations.

All the applicational logging and references to the session userid will point to the administrative user.

I hope this helps.


Cheers,

   Frederico


Rank: #1673

Hi Frederico,

About question 1) , I understand.


About 2), I dont konw  why we shall login in the Timer action.  In my project , we dont login in the Timer action.

>It's also important to implement the login in the Timer action so that you make sure that data is kept >consistent in case of the Timer execution terminates unexpectedly. 


Thanks,

Shake 

mvp_badge
MVP
Rank: #18
Solution

Hi shake mountain,

It has to do with any logging you might be doing in the business logic. If you don't login, any usage of GetUserId() will return NullIdentifier() and you will not be able to immediately determine if the log was generated by regular user that did not login or if it was generated by a timer.

If timers always perform login with the same user (and that user is only used by your timers and internal processes) that means you have a more clear view on what generated logs and can better understand what's going on at any given moment.

Hope this clarifies a bit better what Frederico meant!

Rank: #1673

Hi Jorge,

Thank you very much, I understand now.

Regards