Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Implementing rowlocking

by davidrw (Prior)
on Jan 09, 2007 at 13:06 UTC ( [id://593711]=note: print w/replies, xml ) Need Help??


in reply to Implementing rowlocking

one user might update the row while the other users look at old data. They might make updates of the old data, thereby overwriting the changes of the first user.
first, ditto on using a solid RDBMS--you didn't mention what you're using ..

second, here's something on the app level you can do to help prevent this:
  • put a last_updated (or similarly named) column in your table
  • either add a trigger to set last_updated=NOW on any INSERT/UPDATE, or make sure that your code does so
  • when data is retrieved for the user, keep track (session, hidden var, etc) of not only the row's pk, but also the last_updated
  • when user submits for saving, throw error (or warning screen) if the stored last_updated value for this row is before the current value in the db (meaning someone updated it in the meantime)
Bugzilla used to (may still?) do something similar to this and would throw a "mid-air collision" error message.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://593711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-03-28 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found