#465 ✓ hold
Xavier Noria

about race conditions

Reported by Xavier Noria | September 17th, 2010 @ 08:04 PM | in The Rails 3 Way

Just a comment here, I think "last wins" is OK for the semantics of most web apps. Locking has some use cases of course.

Comments and changes to this ticket

  • Obie

    Obie September 17th, 2010 @ 08:54 PM

    • Milestone set to The Rails 3 Way
    • Milestone order changed from “38” to “0”
  • Obie

    Obie September 18th, 2010 @ 11:45 PM

    • State changed from “new” to “hold”

    You're suggesting that we emphasize that optimistic locking is fine for most web applications?

  • Xavier Noria

    Xavier Noria September 19th, 2010 @ 03:44 AM

    Rather, my comment is that in most cases you can do without locking if you accept the result of the race condition.

    If users u1 and u2 edit the same record, for the semantics of most applications it is fine that the last edit wins. Say for example we have this sequence:

    • user u1 loads model m
    • user u2 loads model m
    • user u1 sends m modified
    • user u2 sends m modified

    Certainly u1 will see later that m does not have his changes, but in most cases this is no different than u2 editing a few seconds later from u1's point of view. Someone else changed it. If u2 decided m had to have that state, that's fine. Same for u1 if u2 submitted the changes first.

    So rather than being the norm, for me is the exception. Perhaps you want to lock a wiki page, but I don't lock the edition of models in general.

  • Xavier Noria

    Xavier Noria September 19th, 2010 @ 05:04 AM

    Just to make myself clear. This comment was motivated by the introduction of the section of locking. It gave me the impression that is telling the user that if concurrency is possible in their app and they are not using some locking mechanism they are doing it wrong. And a series of locking mechanisms are mentioned in the last paragraph.

    The introduction is right in emphasizing that you have to think about what it means in your application, and that you have to decide what to do about it. But I think it would be good to say that in some cases it is fine to do nothing, just accepting "last wins" semantics if they work for your application.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Tags

Pages