How to guarantee only one job working at a time? #41
-
Hi! I tried to use |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 9 replies
-
Hey, You should be able to handle this with .layer(ConcurrencyLimitLayer::new(1))
.... You can read more on the tower docs. |
Beta Was this translation helpful? Give feedback.
-
I tried this: And received |
Beta Was this translation helpful? Give feedback.
-
Could you share a reproducible example? What storage are you using? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Yes.
No programs what never restart. |
Beta Was this translation helpful? Give feedback.
-
After restart:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
After FLUSHDB :
Then after first restart:
After 2 restart:
I think this is a bug. |
Beta Was this translation helpful? Give feedback.
Hey, You should be able to handle this with
ConcurrencyLimitLayer
for one job per worker orGlobalConcurrencyLimitLayer
if you want only one job for all workers.Just do:
You can read more on the tower docs.
The reason you are experiencing this is that jobs are pulled by a thread pool under the hood. So a worker may be running multiple jobs at the same time. Tower has solutions for this.
Let me know this answers your question.