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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:32:58+00:00 2026-06-01T20:32:58+00:00

I’m reading the documentation for Google App Engine and stumbled upon something that I

  • 0

I’m reading the documentation for Google App Engine and stumbled upon something that I don’t quite understand:

The Datastore uses optimistic concurrency to manage transactions. When
two or more application instances try to change the same entity group
at the same time (either by updating existing entities or by creating
new ones), the first application to commit its changes will succeed
and all others will fail on commit. These other applications can then
try their transactions again to apply them to the updated data. Note
that because the Datastore works this way, using entity groups limits
the number of concurrent writes you can do to any entity in a given
group.

Does this mean that if two different users from two different devices try to modify the same object, only one of them will succeed? Is this typical database behavior, or just a GAE limitation? How do other databases usually handle such situations, where two or more users try to modify the same object?

And what does it mean by the fact that when two or more application instances try to create new entities, only one will succeed. Am I understanding that wrong? No two application instances can add a new object to the same table?

  • 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-01T20:33:00+00:00Added an answer on June 1, 2026 at 8:33 pm

    While I can’t speak for document databases like MongoDB and the like (aka NoSQL), I can tell you that relational databases would only allow one operation to take effect. However, this comes down to what the operations are.

    For example, say two users tried to modify the same object. If their modifications only modify a subset of columns, say…

    User 1:

    update MyTable set Col1 = '1', Col2 = '2' where ID = 'abc'
    

    User 2:

    update MyTable set Col2 = 'x', Col3 = 'y' where ID = 'abc'
    

    You can be certain that Col1 will be ‘1’ and Col3' will be 'y', as those two columns were only updated in one statement. The value ofCol2` will be determined by whichever command executed last.

    Likewise, if one user updated the row and another user deleted it, then the row would be deleted no matter what. If the update user’s command came first, then the update would succeed and the row would then be deleted. If the delete command came first, then the row would first be deleted and the update would not do anything since the row doesn’t exist (the where clause would not match any rows).

    However, very few applications actually bother to issue updates to the database with commands that only include changed columns. In almost all applications, commands are created at the table level and they update all columns, then the “current” (changed or not) values are passed into these commands. This is the reason for using optimistic concurrency.

    Assuming that row abc currently has the values:

    ID = 'abc'
    Col1 = '1_original'
    Col2 = '2_original'
    Col3 = '3_original'
    

    And that both users retrieved the row at the same time, our above commands would more realistically look like this:

    User 1:

    update MyTable set Col1 = '1', Col2 = '2', Col3 = '3_original' where ID = 'abc'
    

    User 2:

    update MyTable set Col1 = '1_original', Col2 = 'x', Col3 = 'y' where ID = 'abc'
    

    Now we have a problem; even though our second command really doesn’t care about the value in Col1, it may overwrite the value that was set by User 1. Likewise, if User 2 hit first, then User 1 would overwrite the value written to Col3 by User 2.

    Optimistic concurrency essentially expands the where clause to check the value of every column, not just the key of the table. This way you can be sure that you aren’t overwriting any changes made by someone (or something) else in the time between when you retrieved a row and when you saved it back.

    So, given the same conditions, our commands would look like:

    User 1:

    update MyTable set Col1 = '1', Col2 = '2', Col3 = '3_original' where ID = 'abc' 
            and Col1 = '1_original' and Col2 = '2_original' and Col3 = '3_original'
    

    User 2:

    update MyTable set Col1 = '1_original', Col2 = 'x', Col3 = 'y' where ID = 'abc'
            and Col1 = '1_original' and Col2 = '2_original' and Col3 = '3_original'
    

    This means that whichever command hits the database last won’t actually do anything, since the columns will no longer have their original values.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.