Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Opportunistic and Pesamistic Locking |
Tue, Aug 7 2007 8:29 PM | Permanent Link |
"Adam H." | Hi Tim,
I've got a couple of questions regarding the locking: 1) I was wondering, if there were a number of users connected to a database, and some were using opportunistic locking, and the others pesamistic locking - what happens if two people using different locking methods try and edit the same record? 2) If I use opportunistic locking - is there a way to notify a user that someone else is editing the same record before they go into edit mode. (I have a situation where we want to be able to use opportunistic locking so if someone crashes out, it doesn't leave a record locked - however I also want to warn a user if they start editing a record that is currently being edited by another user - with the option to ignore, or cancel). Thanks & Regards Adam. |
Wed, Aug 8 2007 3:31 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Adam,
<< 1) I was wondering, if there were a number of users connected to a database, and some were using opportunistic locking, and the others pesamistic locking - what happens if two people using different locking methods try and edit the same record? >> They will both be allowed to edit the record, but the one using optimistic locking will get an exception during the Post if the one using pessimistic locking posted changes to the record. If the one using optimistic locking tries to Post the record while the one using pessimistic locking is still editing the record, then the optimistic user will get a record lock exception. The bottom line is that optimistic locking user usually loses to the pessmistic locking user in most cases. << 2) If I use opportunistic locking - is there a way to notify a user that someone else is editing the same record before they go into edit mode. (I have a situation where we want to be able to use opportunistic locking so if someone crashes out, it doesn't leave a record locked - however I also want to warn a user if they start editing a record that is currently being edited by another user - with the option to ignore, or cancel). >> The only way to know for sure is to try and lock the record, and then you basically have pessimistic locking again. The best way to solve the above is to set low connection timeout (but higher than the ping interval used by the remote sessions) and dead session expiration values on the database server and use pinging with the remote sessions. That way any dead sessions will get cleared rather quickly. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Aug 10 2007 5:58 AM | Permanent Link |
Chris Erdal | "Adam H." <ahairsub4@rREMOVEMEspamSTOPPER.jvxp.com> wrote in news:7E251F92-
4D3B-4B98-8F64-2B1ED7B90D33@news.elevatesoft.com: > is there a way to notify a user that > someone else is editing the same record before they go into edit mode One idea I've used for other purposes, but not for this: if you use a positive integer as the primary key, then before you start editing insert a copy of the record into the same table with the key "negativised". Before you allow anyone to modify a record, check whether the negative record is there. After you've posted or cancelled the update, remove the negative version. free bonus: If you add an extra field you can put the current user's name in there, which can be used to remind them what they were doing if the PC crashed while they were modifying the record. The negative record's still there when they open the table next time, and it's got their name in it... 2nd free bonus: If you let them modify the negative version, updating it with EVERY field change as they do it, and overwrite the positive one at the end, then they get all their work-in-hand back after a crash. -- Chris (XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3) |
Sun, Aug 12 2007 9:30 PM | Permanent Link |
"Adam H." | Hi Chris
You have some good suggestions there. Thanks for sharing them with us! Best Regards Adam. |
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |