tetiana

tetiana

Processing jobs during deploy

I am looking for a feedback on how we solve situations we experience with exq:

Situation 1.
On start-up of the node, exq will move any entries in the “backup” queue to the main queue. The issue is when we deploy new version of the app, we have a new instance of the app running, but with the same node id. So exq removes job from the “backup” queue and it’s being performed by new instance, while the older node is still running the job which completes successfully. So we have job executed twice.
Solution:
As suggested in the docs, we can implement a unique node identifier, so then on each deployment we will not touch jobs for previous deployment node.

That leads us to situation 2.
Node 1 (older node) got terminated without finishing all it’s job :astonished_face:
Solution:
Implement backup queue cleaner for previous node. Backup cleaner is a GenServer process which after configurable period of time wakes up, find previous node_id and moves all job belonging to that node_id into a main queue.

Question is, are there a better way to make sure that we don’t re-queuing in-progress jobs during deployment?

Most Liked

OvermindDL1

OvermindDL1

Why not have it not shut down until it’s jobs finish processing, but rather just have it stop taking in new jobs?

tetiana

tetiana

Well, that’s how exq with redis works. It uses backup queues to manage in-progress jobs. When exq performs a job, it takes the job request off the queue and places it into a “backup” queue with a node identifier that will process the job. If the job completes successfully it will remove it from the “backup” queue. If the node crashes for some reason it will remain in the “backup” queue. On start-up of the node, it will move any entries in the “backup” queue and move it back to the main queue, where it will be processed again. The issue is, that when we deploy we have a new instance running, but with the same node id. So it assumes that there has been a crash, removes it from the “backup” queue so the job is performed again, while the older node is still running the job which completes successfully. So, we end up processing job twice. And above I’ve described how we go about that. I think I am pretty happy with the solution we came up. Just wanted to see if that’s an idiomatic way to solve this.

dimitarvp

dimitarvp

So why not combine node ID with a deployment or instance ID (which should change on every start-up) to achieve a unique ID? Or would that break any backwards compatibility with Resque and Sidekiq?

Last Post!

blatyo

blatyo

Conduit Core Team

This is likely what I would do.

Is in order processing important? If it is, then the cleaner would be insufficient. In that case you’d probably want the node name to stay the same and make your jobs idempotent or implement an exactly once guarantee.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement