What would be good ways to design a group of jobs such that they can never run at the same time?
I am looking for a generic concept, like a semaphore, which makes it easier to ensure that some jobs are never running at the same time.
For example, I'm thinking of a "signal table". When a job starts, it sets the signal and at the end, it resets the signal. In addition, every job needs to wait until the signal is set. (How to implement a CPU friendly waiting?) However, when a job crashes, there must then be a solution to automatically reset the signal, otherwise jobs would never start.
We have 4 jobs which are doing various updates, imports, calculations. They all are running by scheduler, and in addition, some of them can also be started manually by super users in case a special run is needed. However, they should not run at the same time, because it often results then in locks or even deadlocks and the database does not properly respond to the users then.
EDIT: It's a data warehouse which is gathering and consolidating data from multiple external data sources. Every job is responsible for another data source, like this:
- job #1 is running every 15 minutes
- job #2 every 3 hours
- job #3 and Job #4 run once per day or have extra runs when started by super users.