Stano,

There are many ways to track what goes on in an application. I suggest you
implement an application based version of "row-locking".

Create a table to hold a list of the IDs that you are currently editing. If
a user requests to edit a person, check that table and if no entry exists
add one otherwise tell your user that that record is already being edited
and they will have to wait.  There are many variations on this method. Some
add the threadID to the table so that one process can determine if it got
the lock or if another thread did.  You can wrap the entire "check-add"
process with a WRITE LOCK just to keep other threads out while you check.

If you are doing this with a browser-based front end, you run the risk of
locking a person's record but never unlocking it. You can specify a time
limit on the lock (just one more column in your tracking table) and if the
user doesn't submit their changes by then you could either deny the
submission or any number of other options.  A process (like the editor page
itself) could scan the lock table for expired locks and clear them out. You
have a lower risk of this if you are building your own front-end as you can
put into your shutdown housekeeping the code to clear any locks that user
may have left open.

The locks that are built into MySQL are not meant for "slow" processes like
people but to keep the database consistent while handling hundreds (or
thousands) of actions per second. Locking a database to prevent changes
during the 1 to 15 minutes it takes to edit a profile would be an extremely
long time to lock down your database as none of your other users would be
able to even read any other records while the lock was in place. There are
ways around that, too (read locking vs write locking), but I still DO NOT
feel that using database locks are the right way to solve your concurrency
issue.

Regards,
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


                                                                                       
                                 
                      Stano Paska                                                      
                                 
                      <stanislav.paska@        To:       [EMAIL PROTECTED]             
                             
                      kios.sk>                 cc:                                     
                                 
                                               Fax to:                                 
                                 
                      06/17/2004 12:25         Subject:  open notify                   
                                 
                      AM                                                               
                                 
                                                                                       
                                 
                                                                                       
                                 




Hi,

I am developing some network application with central database.
I have table of persons and two dialog windows.
One window is for viewing the list of persons, when user doubleclick on
some person, second window appears. On this window user can modify data
about this person. Nothing unusual.

And my question is:

Is there some common technique to notify another user, when he wants
open second dialog with same person, which is opened by first user at
the same time?
Another user sees on list of persons actual data, but this record is
already opened with first user and may be changed. There is possibility
to overwrite data changed by first user.

Has MySQL some capabilities for this? Some row level locking with check,
but no wait.

Thanks for answers.

Stano.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]







-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to