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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:46:33+00:00 2026-06-11T08:46:33+00:00

We are trying to build a system with multiple instances of a service on

  • 0

We are trying to build a system with multiple instances of a service on different machines that share the load of processing.

Each of these will check a table, if there are rows to be processed on that table, it will pick the first, mark it processing, then process it, then mark it done. Rinse repeat.

What is the best way to prevent a racing condition where 2 instances A and B do the following

A (1) read the table, finds row 1 to process,
B (1) reads the table, finds row 1 to process,
A (2) marks it row processing
B (2) Marks it row processing

In a single app we could use locks or mutexs.

I can just put A1 and A2 in a single transaction, is it that simple, or is there a better, faster way to do this?

Should I just turn it on it’s head so that the steps are:

A (1) Mark the next row as mine to process
A (2) Return it to me for processing.

I figure this has to have been solved many times before, so I’m looking for the “standard” solutions, and if there are more than one, benefits and disadvantages.

  • 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-11T08:46:34+00:00Added an answer on June 11, 2026 at 8:46 am

    Transactions are a nice simple answer, with two possible drawbacks:

    1) You might want to check with the fine print of your database. Sometimes the default consistency settings don’t guarantee absolute consistency in every possible circumstance.

    2) Sometimes the pattern of accesses associated with using a database to queue and distribute work is hard on a database that isn’t expecting it.

    One possibility is to look at reliable message queuing systems, which are seem to pretty good match to what you are looking for – worker machines could just read work from a shared queue. Possible jumping-off points are http://en.wikipedia.org/wiki/Message_queue and http://docs.oracle.com/cd/B10500_01/appdev.920/a96587/qintro.htm

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

Sidebar

Related Questions

I am trying to build a system that uses nodejs with express to render
I am trying to build a Recommendation system that could use the information from
G'day guys, trying to build a small invoicing system (that can generate PDF's using
I am trying to build an extremely simple filter system that is based on
I'm trying to label a build that is made of multiple checkouts like this:
I am currently trying to build a small system that read's in a bunch
I'm trying to code a site that will allow multiple people to be working
I'm trying to build out a script that will pull the list of users,
I am trying to build a system which takes in snapshot of a few
i am trying to build a statics system i want list all pages 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.