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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:41:58+00:00 2026-05-20T07:41:58+00:00

Classic producer-consumer-problem. I have x app servers which write records in a DB table

  • 0

Classic producer-consumer-problem.

I have x app servers which write records in a DB table (same DB).

On each server, a service is running which polls the DB table and is supposed to read the oldest entry, process it and delete it.
The issue is now that the services get into a race condition: service on server A starts reading, server B starts reading the same record. I’m a bit stuck on this…I have implemented producer-consumer so often but never across server barriers.

The server cannot talk to each other except over the DB.

Environment is SQL Server 2005 and ASP-NET 3.5.

  • 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-20T07:41:58+00:00Added an answer on May 20, 2026 at 7:41 am

    If you pick up work in a transactional way, only one server can pick it up:

    set transaction isolation level repeatable read
    
    update  top 1 tbl
    set     ProcessingOnServer = HOST_NAME()
    from    YourWorkTable tbl
    where   ProcessingOnServer is null
            and Done = 0
    

    Now you can select the details, knowing the work item is safely assigned to you:

    select  *
    from    YourWorkTable tbl
    where   ProcessingOnServer = HOST_NAME()
            and Done = 0
    

    The function host_name() returns the client name, but if you think it’s safer you can pass in the hostname from your client application.

    We usually add a timestamp, so you can check for servers that took too long to process an item.

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

Sidebar

Related Questions

A classic ASP.NET app - AppSrv + MS SQL DB. Both servers are heavy-lifters
Classic ASP had 'server side includes' so that one could easily design a generic
In Classic ASP, Server.MapPath() doesn't always work properly in the Application_OnStart event within global.asa
This is ASP classic, not .Net. We have to get a way to SFTP
Using classic templates, publishing via FTP to a custom domain. I want to add
The classic Design Patterns: Elements of Reusable Object-Oriented Software actually introduced most of us
In classic ASP there is a global object called Application that is accessed simultaniously
One of those classic programming interview questions... You are given two marbles, and told
Having worked with Classic ASP for about 2 years now by creating a few
As a classic ASP developer about once a year since ASP.NET came out I

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.