Git Product home page Git Product logo

Comments (4)

jrallison avatar jrallison commented on August 31, 2024 2

Hey all,

Sorry for the delay. To give you some background, this project started as a port of Sidekiq to golang. The internals work almost identically. The fetcher in go-workers uses the "reliable_fetch" style as described in Sidekiq's documentation: https://github.com/mperham/sidekiq/wiki/Reliability.

To summarize:

When an instance fetches a message from redis, it uses redis's rpoplpush command to atomically remove the message from the queue and place it in an inprogress queue. This helps to make sure the message isn't lost if say, your go-workers process dies, etc.

The inprogress queue key is generated based on the unique process ID you pass into workers.Configure (shown in the README).

That operation is atomic (assuming the Redis instance doesn't die before persisting the change to disk), and any other process fetching messages will not retrieve the same message.

Once the job finishes, go-workers removes the message from the inprogress queue and fetches another message.

When an instance starts, it first looks at the inprogress queue to see if there are any messages which weren't completed (due to a crash, etc). If there are messages in the inprogress queue, it'll being processing them.

IF you are running multiple instances and passing the same process ID into workers.Configure, then each would view messages that are inprogress from another instance as messages it should process again.

If you aren't, then there are no known issues regarding duplicate job processing (in fact, most of the protections for reliable, unique enqueuing/dequeuing is left up to the redis instance itself!).

If you're still seeing weird behavior and can narrow it down to a test case I can reproduce, then I'd be happy to take a look and help debug!

Thanks,
John

from go-workers.

harlow avatar harlow commented on August 31, 2024

I suspect the issue arises from here:
https://github.com/jrallison/go-workers/blob/master/worker.go#L32-L34

if w.process(message) {
    w.manager.confirm <- message
}

If this is a blocking message then the job would remain in the queue until the work is done. Am I reading that correctly?

from go-workers.

harlow avatar harlow commented on August 31, 2024

IF you are running multiple instances and passing the same process ID into workers.Configure, then each would view messages that are inprogress from another instance as messages it should process again.

thanks @jrallison, I'll bet that's exactly what it is. I had the process id hard coded. Will try it out with dynamic ID based on worker number.

from go-workers.

harlow avatar harlow commented on August 31, 2024

as @maccman just yelled from across the room "the problem was between keyboard and chair"

from go-workers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.