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

Weird issue when kicking off multiple workers #40

Closed
jwoertink opened this issue Jan 22, 2020 · 11 comments
Closed

Weird issue when kicking off multiple workers #40

jwoertink opened this issue Jan 22, 2020 · 11 comments
Assignees

Comments

@jwoertink
Copy link
Contributor

I have this worker that kicks off 4 other workers when it runs. I noticed that when it would kick off, it was like it was picking and choosing which of those 4 it wanted to start running. I decided to move all 4 of those up a level, and still the same issue.

Basically the flow is

  • User logs in
  • If successful, kick off 4 separate workers
  • Redirect user to member's area.

Tailing the logs, I see that there's always at least 1 that runs, but it's literally any combination of the 4.

It basically looks like this:

if user
  PasswordWorker.new(user_id: user.id).enqueue
  EmailWorker.new(user_id: user.id).enqueue
  LoginWorker.new(user_id: user.id).enqueue
  PostbackWorker.new(user_id: user.id).enqueue
  redirect to: "/path"
end

Please include some details:

Crystal version: 0.31.1
Mosquito Shard version: commit: 0212a74

@robacarp
Copy link
Collaborator

@jwoertink In the example you gave, are you saying that it only runs the PasswordWorker, but not EmailWorker, LoginWorker, etc?

@jwoertink
Copy link
Contributor Author

In that example, I'm saying that it may run all 4, or it may run just the LoginWorker, or it may run only the PasswordWorker and the PostbackWorker.... Like every permutation of those. It doesn't really make sense, but my guess is all of them get shoved in to redis, but only some get pulled back out.

@robacarp
Copy link
Collaborator

@jwoertink wow, that's significant. Thanks for reporting. I have a feeling it's going to be difficult to reproduce.

@jwoertink
Copy link
Contributor Author

I'm sure. We just launched this in to production yesterday, so we're just now seeing it. I'm gonna do more digging in, but you know how it goes with the lack of debugging tools in crystal 😅 I'll let you know if I come up with any additional info.

@robacarp
Copy link
Collaborator

@jwoertink can you go into more detail about your deployment? I'm curious how many task runners you have, for example.

@jwoertink
Copy link
Contributor Author

oh, I didn't even think about that.

require "./shards"
require "./workers/*"

Mosquito::Runner.start

I'm just running

crystal build src/mosquito.cr --release -o worker
./worker

So I never actually specified the number of workers or anything. What does that config look like?

@robacarp
Copy link
Collaborator

By default it's just the one worker. I meant spinning up ./worker more than once, possibly on multiple boxes.

@jwoertink
Copy link
Contributor Author

We only have the one server, so only 1 process for that running.

@robacarp
Copy link
Collaborator

@jwoertink you mentioned you might do some digging, did anything get dug up?

@jwoertink
Copy link
Contributor Author

I did indeed, and I did a horrible job with that 😢 sorry about that. I tried a few different things, but I was never able to recreate it outside of the app. My guess is we must have been doing something weird.

You can close this out for now if you'd like, and if I end up getting a better code example, I can always just reopen it.

@robacarp
Copy link
Collaborator

No worries! Thanks for checking back in. Please re-open if needed.

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

No branches or pull requests

2 participants