Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semaphore or Mutex is not actually implemented yet. #9

Open
key-amb opened this issue Jun 7, 2015 · 0 comments
Open

Semaphore or Mutex is not actually implemented yet. #9

key-amb opened this issue Jun 7, 2015 · 0 comments

Comments

@key-amb
Copy link
Collaborator

key-amb commented Jun 7, 2015

The title is truth for current release of Koyomi (v0.4.1 at June 6th, 2015).
Currently, when using MySQL datastore, we avoid coincident execution of jobs in the following way:

  1. Update the semaphores record corresponding to the job when first worker executes it.
  2. When second or third worker tries to execute the job, they check the semaphores record at first. And they know first worker now executed the job, then quit.

In addition, when several workers execute the same job on exactly same time, each of them run a transaction with optimistic lock on updating the semaphores record.
As a result, only one worker can get the lock and execute the job.

In this way, we can avoid coincident execution of jobs.
On the other hand, if one job takes longer time than its interval, the next job is to be started again before the previous job ends. So the same jobs can run concurrently.

Introducing "semaphore" or "mutex", we can avoid this concurrent execution of jobs.

I think it would be nicer than current implementation.
But if some of you don't like "semaphore" or "mutex", maybe I will make it optional so that you could opt it out.

Any feedback is welcome.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant