NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL concurrency 101

David Sklar sklar at sklar.com
Thu Dec 11 12:55:01 EST 2003


> yeah but what if two
> users SELECT the same data simultaneously. Answer:  not your problem.
> If they both try to write one of them will just have to suffer a
> little inconvenience, for data integrity's sake.

Depending on how much work you want to do to prevent users from having to do
some work, you can eliminate the user inconvenience in certain
circumstances.

For example, if the two users have relative permissions or roles where it
makes sense for one of them to overwrite the others' changes, then you don't
have to re-prompt.

Or, if both users updates can be mutually compatible, then you can save both
of them with no changes. If both users have edited a text field, you can
behave like CVS -- use diff to see if the users have made changes only to
non-intersecting parts of the text field and if so, silently save both sets
of changes.

However, in practice, the "little inconvenience" that users may suffer in
this situation is usually a good thing. Simultaneous conflicting alteration
of data by two people probably means there is a workflow or business problem
with human communication and human organization -- so if your application
highlights it, the humans involved can work to fix it. ("Oh, you're handling
the updates for the customers that live in Connecticut? I though I was
supposed to be doing those.").

David




More information about the talk mailing list