-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Problem: No persistent Quantum State #240
Comments
Replacement of #238 |
Currently there are two popular job scheduling libraries for Elixir: Exq and Quantum-Elixir. Exq is Redis-backed, so jobs don't get lost if application restarts. However, it cannot be configured to run jobs at regular intervals. Quantum-Elixir can run jobs at regular intervals, but it has no persistent state for Quantums. This is a predicament: robust, "real-life" job scheduling functionality is currently split between these two libraries, with neither one providing the full functionality. That's why I think this feature should be high priority. |
I think that you could use ETS and PersistentEts as a storage state system, instead of leave to the user that implementation. |
@Yamilquery I'm aware that there are many options for the storage backend. This is not really a complex feature but requires a decent amount of work. If you'd like to tackle this, you're very welcome to do provide a PR. As mentioned in the requirements section please do not implement to one specific storage backend but rather write a protocol so that other implementations can be built. |
Why do you guys insist on this generic mul;ti-backend implementation as if your really reaaly know that it really is a critical for some use cases, while the whole persistence capability (which obviously is critical) is missing. Why not just start off with a feasible DETS/Mnesia implementation and go ahead with it? |
My plan was to implement a behaviour for the adapter and one implementation. (not sure yet what I would pick first) The reason this is not long done is that I currently lack the time to do all this. If you'd like to volunteer, I could define the behaviour / config etc. in a PR and you could provide the first implementation of the storage. Does that sound like an option to you?
I don't think that defining a behaviour is very demanding. This library is fairly popular by now and I don't see lowering standards as an option. |
@pyatkov https://github.com/c-rack/quantum-elixir/blob/storage/lib/quantum/storage/adapter.ex Please tell me if there is something wrong with the interface or if you have ideas for improvements. |
@c-rack Would you prefer if storage providers live in their own package or if we manage them here? Edit: Depending on the adapter type this could introduce many new optional dependencies like redix etc. which could collide with the installers setup. I think it would be better if the adapters were in its own package. |
@maennchen |
Do you work based on https://github.com/c-rack/quantum-elixir/tree/storage ?
Great, I'm eager to see your PR.
This is one of the core features of the current Therefore the only interesting value for the storage is the
Yes, we treat the job name as unique. |
@maennchen |
@maennchen |
Since there could be multiple instances of the
The internal structure of quantum heavily depends on messaging. Only relevant information for a given action is part of the message. Therefore many of those events are not ware of the full job.
Those are the low-level needed function to connect to quantum. For sure we can add more convenience methods to the storage.
In my opinion the storage is a backend of quantum and should not have any execution logic by itself. Why would you want to save information that is not actually needed by the scheduler? Also important to know is how quantum is built internally (mostly for performance and keeping parts small and maintainable). Not all stages have a full copy of a job and also do not need them. Currently jobs behave a lot like elixir variables: They are immutable in the system (with the exception of state active / inactive). If you add a new job with the same name, the old one will be overwritten.
If you look into the new branch, you can already see this functionality implemented.
What happens if I want to use the same Storage Implementation on two schedulers? |
@maennchen Also, I see 3 types of jobs regarding redo option:
So, based on this job type (so to speak) and the Also, probably not related to this issue (and PR), I was thinking of a neat way to execute one-time jobs, that need to be fired at the given datetime and removed froum the scheduler upon execution. I know it could be done by removing the job from the scheduler upon job task completion, but a more neat way to do it (like configure the job to be a |
Yes, because the execution broadcaster moves through time only if its job is done at the instant it was working on.
Only if you kill (not stop) the execution supervisor. (If you for example pull the plug.)
Could we tackle that problem after the storage itself is done? This needs some work on other parts of the library as well and I would like to stabilise the storage interface first. (Don't take this as missing interest, I think that is an important point.)
We have currently no option for that. I created #268 to see if there is interest for that. |
Looked at PR #313 - solid work (especialy on the test side and logging stuff :-) ) |
Glad to hear that. I hope it is a good base to solve the problems. (I do expect that we'll need to change things, but it should be a good starting point.)
It was my idea that you could either start multiple GenServers for the storage and get the right one based on the scheduler_name or partitions on the storage. (If you have a better idea how to handle multiple schedulers we can change that.)
Since there are really clear boundaries between the stages, I hope you find everything. If you have any questions, do not hesitate to ask! |
@maennchen |
@maennchen |
Description
Currently quantum does not persist any state. Therefore if an application is restarted, all dynamic jobs are lost. Also in the time that has passed since the restart happened no jobs has been executed and there is no way to let them redo the lost time.
Minimal Requirements
I don''t think that Quantum should choose a storage backend and implement it since this heavily depends on the application where it is integrated in. I propose that we just develop protocols for such a storage and let the implementation to the user of the library. (Where this person can decide if he wants to use redis / postgres / mnesia / whatever to ensure persistence)
Implementation
I heavily recommend waiting for PR #230 before implementing any changes.The storage would have to be inserted in two places:
JobBroadcaster
init
init
write config jobs:add
:delete
:change_state
:delete_all
ExecutionBroadcaster
init
redo
is active:execute
PR
Since this is a fairly big implementation, we'd be happy to receive a PR. If this is a popular request please leave a 👍 so that we see that this is important to our users and implement it ourselves.
The text was updated successfully, but these errors were encountered: