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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:26:20+00:00 2026-05-25T02:26:20+00:00

Here are two potential workflows I would like to perform in a web application.

  • 0

Here are two potential workflows I would like to perform in a web application.

Variation 1

  • user sends request
  • server reads data
  • server modifies data
  • server saves modified data

Variation 2:

  • user sends request
  • server reads data
  • server sends data to user
  • user sends request with modifications
  • server saves modified data

In each of these cases, I am wondering: what are the standard approaches to ensuring that concurrent access to this service will produce sane results? (i.e. nobody’s edit gets clobbered, values correspond to some ordering of the edits, etc.)

The situation is hypothetical, but here are some details of where I would likely need to deal with this in practice:

  • web application, but language unspecified
  • potentially, using a web framework
  • data store is a SQL relational database
  • the logic involved is too complex to express well in a query e.g. value = value + 1

I feel like I would prefer not to try and reinvent the wheel here. Surely these are well known problems with well known solutions. Please advise.

Thanks.

  • 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-25T02:26:21+00:00Added an answer on May 25, 2026 at 2:26 am

    To the best of my knowledge, there is no general solution to the problem.

    The root of the problem is that the user may retrieve data and stare at it on the screen for a long time before making an update and saving.

    I know of three basic approaches:

    1. When the user reads the database, lock the record, and don’t release until the user saves any updates. In practice, this is wildly impractical. What if the user brings up a screen and then goes to lunch without saving? Or goes home for the day? Or is so frustrated trying to update this stupid record that he quits and never comes back?

    2. Express your updates as deltas rather than destinations. To take the classic example, suppose you have a system that records stock in inventory. Every time there is a sale, you must subtract 1 (or more) from the inventory count.

    So say the present quantity on hand is 10. User A creates a sale. Current quantity = 10. User B creates a sale. He also gets current quantity = 10. User A enters that two units are sold. New quantity = 10 – 2 = 8. Save. User B enters one unit sold. New quantity = 10 (the value he loaded) – 1 = 9. Save. Clearly, something went wrong.

    Solution: Instead of writing “update inventory set quantity=9 where itemid=12345”, write “update inventory set quantity=quantity-1 where itemid=12345”. Then let the database queue the updates. This is very different from strategy #1, as the database only has to lock the record long enough to read it, make the update, and write it. It doesn’t have to wait while someone stares at the screen.

    Of course, this is only useable for changes that can be expressed as a delta. If you are, say, updating the customer’s phone number, it’s not going to work. (Like, old number is 555-1234. User A says to change it to 555-1235. That’s a change of +1. User B says to change it to 555-1243. That’s a change of +9. So total change is +10, the customer’s new number is 555-1244. 🙂 ) But in cases like that, “last user to click the enter key wins” is probably the best you can do anyway.

    1. On update, check that relevant fields in the database match your “from” value. For example, say you work for a law firm negotiating contracts for your clients. You have a screen where a user can enter notes about negotiations. User A brings up a contract record. User B brings up the same contract record. User A enters that he just spoke to the other party on the phone and they are agreeable to the proposed terms. User B, who has also been trying to call the other party, enters that they are not responding to phone calls and he suspects they are stonewalling. User A clicks save. Do we want user B’s comments to overwrite user A’s? Probably not. Instead we display a message indicating that the notes have been changed since he read the record, and allowing him to see the new value before deciding whether to proceed with the save, abort, or enter something different.

    [Note: the forum is automatically renumbering my numbered lists. I’m not sure how to override this.]

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

Sidebar

Related Questions

I have a very strange behavior with Request.Form . Here are two IIS 7
Here are two different questions but I think they are related. When using Git,
Here are two chunks of code that accomplish (what I think is) the same
Here are two questions related to modifying the data source for strongly typed dataset
Here's two screen shots, showing the effect with a small viewport that has to
Here is two variants. First: int n = 42; int* some_function(int* input) { int*
I have a question, here are two classes below: class Base{ public: virtual void
If you want to associate some constant value with a class, here are two
I have a menu bar that is rotated slightly. Here are two buttons as
So two questions here: If I use <input type=button onclick=validate()> then the enter key

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.