Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:51:06+00:00 2026-06-18T09:51:06+00:00

I have a background job that does a map/reduce job on MongoDB. When the

  • 0

I have a background job that does a map/reduce job on MongoDB. When the user sends in more data to the document, it kicks of the background job that runs on the document. If the user sends in multiple requests, it will kick off multiple background jobs for the same document, but only one really needs to run. Is there a way I can prevent multiple duplicate instances? I was thinking of creating a queue for each document and making sure it is empty before I submit a new job. Or perhaps I can set a job id somehow that is the same as my document id, and check that none exists before submitting it?

Also, I just found a sidekiq-unique-jobs gem. But the documentation is non-existent. Does this do what I want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:51:08+00:00Added an answer on June 18, 2026 at 9:51 am

    My initial suggestion would be a mutex for this specific job. But as there’s a chance that you may have multiple application servers working the sidekiq jobs, I would suggest something at the redis level.

    For instance, use redis-semaphore within your sidekiq worker definition. An untested example:

    def perform
      s = Redis::Semaphore.new(:map_reduce_semaphore, connection: "localhost")
    
      # verify that this sidekiq worker is the first to reach this semaphore.
      unless s.locked?
    
        # auto-unlocks in 90 seconds. set to what is reasonable for your worker.
        s.lock(90)
        your_map_reduce()
        s.unlock
      end
    end
    
    def your_map_reduce
      # ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if i have a php background job, may need to run 4-5hours or more
Does anyone know of a background job manager that works with Rails 3? I
We have to use delayed_job (or some other background-job processor) to run jobs in
I need to have background Music in my website, With user oN and OFF
I have this background image that is 175x175 but I am trying to make
I have a background image that is 1024 x 1024 pixels; the reason for
I have heard a myth that a job will finish faster if it is
Does anyone know a working background job solution for JRuby deployed on a windows
I have a GUI application that process some data, it converts line of text
I have a background thread doing some processing, and saving to Core Data. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.