You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✔ Server is ready on port: 9000 – 1ms
Starting job 1728754080010
Starting job 1728754140007
Finished job 1728754080010
Starting job 1728754200009
Finished job 1728754140007
As you can see, the next execution of the scheduled job started before the current one finishes.
Is there a way to make a Scheduled Job skip an execution until the current job has finished?
Why?
I'm implementing an integration with a third-party service that provides product and order information. I can imagine that there might be a case where the new incoming data from the remote service won't be processed before the next execution of the job, which might lead to a race condition.
Maybe Scheduled Jobs are not suitable for my use case, but I'll be happy to hear any ideas.
UPD 13.10.2024:
The medusa documentation recommends using a scheduled job to synchronise with a third party system, but unfortunately it's not clear to me how to avoid the potential race condition.
Possible solutions I can see so far
Add a configuration flag to the Scheduled Job configuration to ensure that the next run doesn't happen until the current one has finished.
Provide a way to create a Scheduled Job at runtime, so that when the job finishes we can schedule the next execution time (withnumberOfExecution set to 1).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As an experiment I created the following job:
As a result I have the following in the console:
As you can see, the next execution of the scheduled job started before the current one finishes.
Is there a way to make a Scheduled Job skip an execution until the current job has finished?
Why?
I'm implementing an integration with a third-party service that provides product and order information. I can imagine that there might be a case where the new incoming data from the remote service won't be processed before the next execution of the job, which might lead to a race condition.
Maybe Scheduled Jobs are not suitable for my use case, but I'll be happy to hear any ideas.
UPD 13.10.2024:
The medusa documentation recommends using a scheduled job to synchronise with a third party system, but unfortunately it's not clear to me how to avoid the potential race condition.
Possible solutions I can see so far
numberOfExecution
set to 1).Beta Was this translation helpful? Give feedback.
All reactions