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 3680282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:33:30+00:00 2026-05-19T03:33:30+00:00

Suppose I have ten cron jobs running in parallel which fetch entries from database

  • 0

Suppose I have ten cron jobs running in parallel which fetch entries from database and process them.

The first cron job gets all the entries from database which have ‘commonId’ field as 1,
the second one gets all the entries from database which have ‘commonId’ field as 2 and so on till 10.

Solution –
When I am adding entries to the database from front-end, I have a file that has the “last” common id saved in it. This id is incremented till 10 and is then again set to 1 for each entry in database.

Hurdle –
There are lots of users on front end and when adding the entries, a same common id is used for two or three consecutive entries. This should not happen. Every entry in database should have serial common id from 1-10.

Is there any solution for this? To get the latest of latest common id?

I’m using MongoDB.

If this isn’t possible. What could be done?

  • 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-05-19T03:33:30+00:00Added an answer on May 19, 2026 at 3:33 am

    What you want is an ATOMIC operation and MongoDB has ways to do those. See http://www.mongodb.org/display/DOCS/Atomic+Operations

    Any reason you specifically want to allocate them round robin like that? Wouldn’t it process faster if you allowed any of the chron jobs to consume any pending job?

    I suggest simply relying on the generated MongoID’s (see http://www.mongodb.org/display/DOCS/Object+IDs#ObjectIDs-TheBSONObjectIdDatatype), reverse order by them and find the first unallocated work item, grab it using one of the atomic techniques mentioned. If no work is found, sleep and try again or quit (depending on how often your chron job is rescheduling these workers).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have logged into an application which is running from IIS . Now
Suppose that I write some JavaScript code that displays the first ten records from
Suppose I have a list, in which no new nodes are added or deleted.
Suppose I have a method which changes the state of an object, and fires
Ok, so suppose. I have ten images in documents.images array. When I click on
Suppose I have a class MyClass to which I want to add certain 'observer'
Suppose I have a ASP.NET Web API controller that uses a service, which in
Suppose I have 20 string of different length, each of them is supposed to
Suppose i have a cookie set in first.com say user. Now i want to
Suppose I have a FruitDetector class which takes in a string and returns the

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.