Original Post
Hi! I have a problem with an application that uses a database for storing the state of different arbitary jobs to run. The issue I'm having is that if a job of a specific type is running, no other job with the same type may start, and sometimes if the application is forcibly shutdown - the state of an ongoing job might not be updated. For example: I have 3 jobs in the database, "Job1" was started but due to the application beeing forcibly shutdown, it will never complete and the status will be kept at "Running" - which will not allow the "Job3" to start, since they both have the same job type "JobType1": Job1 | JobType1 | Running Job2 | JobType2 | Finished Job3 | JobType1 | Pending I'm thinking I could add something like a "Timeout" value, which says how long a job may be running until it is treated as "Closed" and if it is already running it is terminated, thus allowing "Job3" to begin. However, I would preffer that jobs are allowed to run any amount of time, until it is actually completed. So, can someone give me input on how this can be done, or at least point me in the right direction - I'm guessing there should be some relevant concept solving this kind of synchronization issue. Basically what I want is to have a database with jobs, and multiple applications consuming the jobs. Thank you.