Re: Transactions and Locking Rows for Update

Dale,
Sounds like you either need an "optimistic locking" scheme, usually
implemented with timestamps at the database level, or a concurrency manager.
A concurrency manager registers objects that may be of interest to multiple
users in a central location. It takes care of notifying interested parties
(i.e., clients,) of changes made to those objects, using a "notifier" pattern.
The optimistic locking scheme is relatively easy to implement at the
database level, but introduces several problems. One problem is that the
first person to save their changes "wins" - every one else has to discard
their changes. Also, you now have business policy effectively embedded in
the database.
The concurrency manager is much more flexible, and keeps the policy where
it probably belongs. However, it is more complex, and there are some
implications to performance when you get to the multiple-thousand-user
range because of its event-based nature.
Another pattern of lock management that has been implemented is a
"key-based" lock manager that does not use events, and may be more
effective at managing this type of concurrency for large numbers of users.
There are too many details to go into here, but I may be able to give you
more ideas in a separate note, if you want.
Don
At 04:48 PM 6/5/97 PDT, Dale "V." Georg wrote:
I have a problem in the application I am currently working on, which it
seems to me should be easily solvable via appropriate use of transactions
and database locking, but I'm having trouble figuring out exactly how to
do it. The database we are using is Oracle 7.2.
The scenario is as follows: We have a window where the user picks an
object from a dropdown list. Some of the object's attributes are then
displayed in that window, and the user then has the option of editing
those attributes, and at some point hitting the equivalent of a 'save'button
to write the changes back to the database. So far, so good. Now
introduce a second user. If user #1 and user #2 both happen to pull up
the same object and start making changes to it, user #1 could write back
to the database and then 15 seconds later user #2 could write back to the
database, completely overlaying user #1's changes without ever knowing
they had happened. This is not good, particularly for our application
where editing the object causes it to progress from one state to the next,
and multiple users trying to edit it at the same time spells disaster.
The first thing that came to mind was to do a select with intent to update,
i.e. 'select * from table where key = 'somevalue' with update'. This way
the next user to try to select from the table using the same key would not
be able to get it. This would prevent multiple users from being able to
pull the same object up on their screens at the same time. Unfortunately,
I can think of a number of problems with this approach.
For one thing, the lock is only held for the duration of the transaction, so
I would have to open a Forte transaction, do the select with intent to
update, let the user modify the object, then when they saved it back again
end the transaction. Since a window is driven by the event loop I can't
think of any way to start a transaction, let the user interact with the
window, then end the transaction, short of closing and re-opening the
window. This would imply having a separate window specifically for
updating the object, and then wrapping the whole of that window's event
loop in a transaction. This would be a different interface than we wanted
to present to the users, but it might still work if not for the next issue.
The second problem is that we are using a pooled DBSession approach
to connecting to the database. There is a single Oracle login account
which none of the users know the password to, and thus the users
simply share DBSession resources. If one user starts a transaction
and does a select with intent to update on one DBSession, then another
user starts a transaction and tries to do the same thing on the same
DBSession, then the second user will get an error out of Oracle because
there's already an open transaction on that DBSession.
At this point, I am still tossing ideas around in my head, but after
speaking with our Oracle/Forte admin here, we came to the conclusion
that somebody must have had to address these issues before, so I
thought I'd toss it out and see what came back.
Thanks in advance for any ideas!
Dale V. Georg
Indus Consultancy Services [email protected]
Mack Trucks, Inc. [email protected]
>
>
>
>
====================================
Don Nelson
Senior Consultant
Forte Software, Inc.
Denver, CO
Corporate voice mail: 510-986-3810
aka: [email protected]
====================================
"I think nighttime is dark so you can imagine your fears with less
distraction." - Calvin

We have taken an optimistic data locking approach. Retrieved values are
stored as initial values; changes are stored seperately. During update, key
value(s) or the entire retieved set is used in a where criteria to validate
that the data set is still in the initial state. This allows good decoupling
of the data access layer. However, optimistic locking allows multiple users
to access the same data set at the same time, but then only one can save
changes, the rest would get an error message that the data had changed. We
haven't had any need to use a pessimistic lock.
Pessimistic locking usually involves some form of open session or DBMS level
lock, which we haven't implemented for performance reasons. If we do find the
need for a pessimistic lock, we will probably use cached data sets that are
checked first, and returned as read-only if already in the cache.
-DFR
Dale V. Georg <[email protected]> on 06/05/97 03:25:02 PM
To: Forte User Group <[email protected]> @ INTERNET
cc: Richards* Debbie <[email protected]> @ INTERNET, Gardner*
Steve <[email protected]> @ INTERNET
Subject: Transactions and Locking Rows for Update
I have a problem in the application I am currently working on, which it
seems to me should be easily solvable via appropriate use of transactions
and database locking, but I'm having trouble figuring out exactly how to
do it. The database we are using is Oracle 7.2.
The scenario is as follows: We have a window where the user picks an
object from a dropdown list. Some of the object's attributes are then
displayed in that window, and the user then has the option of editing
those attributes, and at some point hitting the equivalent of a 'save' button
to write the changes back to the database. So far, so good. Now
introduce a second user. If user #1 and user #2 both happen to pull up
the same object and start making changes to it, user #1 could write back
to the database and then 15 seconds later user #2 could write back to the
database, completely overlaying user #1's changes without ever knowing
they had happened. This is not good, particularly for our application
where editing the object causes it to progress from one state to the next,
and multiple users trying to edit it at the same time spells disaster.
The first thing that came to mind was to do a select with intent to update,
i.e. 'select * from table where key = 'somevalue' with update'. This way
the next user to try to select from the table using the same key would not
be able to get it. This would prevent multiple users from being able to
pull the same object up on their screens at the same time. Unfortunately,
I can think of a number of problems with this approach.
For one thing, the lock is only held for the duration of the transaction, so
I would have to open a Forte transaction, do the select with intent to
update, let the user modify the object, then when they saved it back again
end the transaction. Since a window is driven by the event loop I can't
think of any way to start a transaction, let the user interact with the
window, then end the transaction, short of closing and re-opening the
window. This would imply having a separate window specifically for
updating the object, and then wrapping the whole of that window's event
loop in a transaction. This would be a different interface than we wanted
to present to the users, but it might still work if not for the next issue.
The second problem is that we are using a pooled DBSession approach
to connecting to the database. There is a single Oracle login account
which none of the users know the password to, and thus the users
simply share DBSession resources. If one user starts a transaction
and does a select with intent to update on one DBSession, then another
user starts a transaction and tries to do the same thing on the same
DBSession, then the second user will get an error out of Oracle because
there's already an open transaction on that DBSession.
At this point, I am still tossing ideas around in my head, but after
speaking with our Oracle/Forte admin here, we came to the conclusion
that somebody must have had to address these issues before, so I
thought I'd toss it out and see what came back.
Thanks in advance for
any
ideas!
Dale V. Georg
Indus Consultancy Services [email protected]
Mack Trucks, Inc. [email protected]
------ Message Header Follows ------
Received: from pebble.Sagesoln.com by notes.bsginc.com
(PostalUnion/SMTP(tm) v2.1.9c for Windows NT(tm))
id AA-1997Jun05.162418.1771.334203; Thu, 05 Jun 1997 16:24:19 -0500
Received: (from sync@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
NAA11825 for forte-users-outgoing; Thu, 5 Jun 1997 13:47:58 -0700
Received: (from uucp@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
NAA11819 for <[email protected]>; Thu, 5 Jun 1997 13:47:56 -0700
Received: from unknown(207.159.84.4) by pebble.sagesoln.com via smap (V1.3)
id sma011817; Thu Jun 5 13:47:43 1997
Received: from tes0001.macktrucks.com by relay.macktrucks.com
via smtpd (for pebble.sagesoln.com [206.80.24.108]) with SMTP; 5 Jun
1997 19:35:31 UT
Received: from dale by tes0001.macktrucks.com (SMI-8.6/SMI-SVR4)
id QAA04637; Thu, 5 Jun 1997 16:45:51 -0400
Message-ID: <[email protected]>
Priority: Normal
To: Forte User Group <[email protected]>
Cc: "Richards," Debbie <[email protected]>,
"Gardner," Steve <[email protected]>
MIME-Version: 1.0
From: Dale "V." Georg <[email protected]>
Subject: Transactions and Locking Rows for Update
Date: Thu, 05 Jun 97 16:48:37 PDT
Content-Type: text/plain; charset=US-ASCII; X-MAPIextension=".TXT"
Content-Transfer-Encoding: quoted-printable
Sender: [email protected]
Precedence: bulk
Reply-To: Dale "V." Georg <[email protected]>

Similar Messages

  • Transactions and Locking Rows for Update

    I have a problem in the application I am currently working on, which it
    seems to me should be easily solvable via appropriate use of transactions
    and database locking, but I'm having trouble figuring out exactly how to
    do it. The database we are using is Oracle 7.2.
    The scenario is as follows: We have a window where the user picks an
    object from a dropdown list. Some of the object's attributes are then
    displayed in that window, and the user then has the option of editing
    those attributes, and at some point hitting the equivalent of a 'save' button
    to write the changes back to the database. So far, so good. Now
    introduce a second user. If user #1 and user #2 both happen to pull up
    the same object and start making changes to it, user #1 could write back
    to the database and then 15 seconds later user #2 could write back to the
    database, completely overlaying user #1's changes without ever knowing
    they had happened. This is not good, particularly for our application
    where editing the object causes it to progress from one state to the next,
    and multiple users trying to edit it at the same time spells disaster.
    The first thing that came to mind was to do a select with intent to update,
    i.e. 'select * from table where key = 'somevalue' with update'. This way
    the next user to try to select from the table using the same key would not
    be able to get it. This would prevent multiple users from being able to
    pull the same object up on their screens at the same time. Unfortunately,
    I can think of a number of problems with this approach.
    For one thing, the lock is only held for the duration of the transaction, so
    I would have to open a Forte transaction, do the select with intent to
    update, let the user modify the object, then when they saved it back again
    end the transaction. Since a window is driven by the event loop I can't
    think of any way to start a transaction, let the user interact with the
    window, then end the transaction, short of closing and re-opening the
    window. This would imply having a separate window specifically for
    updating the object, and then wrapping the whole of that window's event
    loop in a transaction. This would be a different interface than we wanted
    to present to the users, but it might still work if not for the next issue.
    The second problem is that we are using a pooled DBSession approach
    to connecting to the database. There is a single Oracle login account
    which none of the users know the password to, and thus the users
    simply share DBSession resources. If one user starts a transaction
    and does a select with intent to update on one DBSession, then another
    user starts a transaction and tries to do the same thing on the same
    DBSession, then the second user will get an error out of Oracle because
    there's already an open transaction on that DBSession.
    At this point, I am still tossing ideas around in my head, but after
    speaking with our Oracle/Forte admin here, we came to the conclusion
    that somebody must have had to address these issues before, so I
    thought I'd toss it out and see what came back.
    Thanks in advance for any ideas!
    Dale V. Georg
    Indus Consultancy Services [email protected]
    Mack Trucks, Inc. [email protected]
    [email protected]------------------

    I have a problem in the application I am currently working on, which it
    seems to me should be easily solvable via appropriate use of transactions
    and database locking, but I'm having trouble figuring out exactly how to
    do it. The database we are using is Oracle 7.2.
    The scenario is as follows: We have a window where the user picks an
    object from a dropdown list. Some of the object's attributes are then
    displayed in that window, and the user then has the option of editing
    those attributes, and at some point hitting the equivalent of a 'save' button
    to write the changes back to the database. So far, so good. Now
    introduce a second user. If user #1 and user #2 both happen to pull up
    the same object and start making changes to it, user #1 could write back
    to the database and then 15 seconds later user #2 could write back to the
    database, completely overlaying user #1's changes without ever knowing
    they had happened. This is not good, particularly for our application
    where editing the object causes it to progress from one state to the next,
    and multiple users trying to edit it at the same time spells disaster.
    The first thing that came to mind was to do a select with intent to update,
    i.e. 'select * from table where key = 'somevalue' with update'. This way
    the next user to try to select from the table using the same key would not
    be able to get it. This would prevent multiple users from being able to
    pull the same object up on their screens at the same time. Unfortunately,
    I can think of a number of problems with this approach.
    For one thing, the lock is only held for the duration of the transaction, so
    I would have to open a Forte transaction, do the select with intent to
    update, let the user modify the object, then when they saved it back again
    end the transaction. Since a window is driven by the event loop I can't
    think of any way to start a transaction, let the user interact with the
    window, then end the transaction, short of closing and re-opening the
    window. This would imply having a separate window specifically for
    updating the object, and then wrapping the whole of that window's event
    loop in a transaction. This would be a different interface than we wanted
    to present to the users, but it might still work if not for the next issue.
    The second problem is that we are using a pooled DBSession approach
    to connecting to the database. There is a single Oracle login account
    which none of the users know the password to, and thus the users
    simply share DBSession resources. If one user starts a transaction
    and does a select with intent to update on one DBSession, then another
    user starts a transaction and tries to do the same thing on the same
    DBSession, then the second user will get an error out of Oracle because
    there's already an open transaction on that DBSession.
    At this point, I am still tossing ideas around in my head, but after
    speaking with our Oracle/Forte admin here, we came to the conclusion
    that somebody must have had to address these issues before, so I
    thought I'd toss it out and see what came back.
    Thanks in advance for any ideas!
    Dale V. Georg
    Indus Consultancy Services [email protected]
    Mack Trucks, Inc. [email protected]
    [email protected]------------------

  • Lock table for update in adf

    dear all ,
    am using Jdeveloper 11.1.1.3 with oracle database 10g,
    now what i need to do is when inserting a new row in one of my entities i need to lock the entire database table until the commit happen...
    i'll explain to u why I need to do this,,, let say that the table x contains the following columns
    x_pk number, ( which is the primary key )
    x_serial number,
    x_type varchar2 );
    now am getting x_pk from a sequence on a database so its not a problem,
    but for x_serial it needs to be serialized per x_type , now in oracle forms developer i used to do the following in per-insert trigger on the block level-->
    lock table for update then selecting the max serial per the type then use it for setting the :x_serial that is in the same block...
    now in ADF , i should do this in the do_dml when the operation==DML_INSERT but am not sure what to write and if it will be working same as it was in the form developer
    thanks ,
    Lama

    Delta,
    I wrote a [url http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/]blog post some time ago for an earlier version of JDeveloper that implemented some custom locking behaviour for EOs - perhaps you can adapt the technique there to your needs?
    John

  • Can we hav call transaction and session method for an application

    can we hav call transaction and session method for an application ?if yes how?

    Hi ,
    You can.  If Call Transaction fails, a batch input session can be created.
    Check this example-
    Call the transaction. Messages from Call Transaction are stored in the
    internal table messtab 
      CALL TRANSACTION 'LT01' USING bdc_tab MODE 'N' UPDATE 'S'
          MESSAGES INTO messtab.
      IF sy-subrc = 0.                                                 
    Call transaction successfull,  get the number of the Transfer Order that
    was created                                                        
        LOOP AT messtab.                                               
          IF messtab-dynumb = '0104' AND messtab-msgnr = '016'.        
            w_transportorderno = messtab-msgv1.                        
          ENDIF.                                                       
        ENDLOOP.
      ELSE.
    Call transaction failed, create a batch input session instead.
        PERFORM open_group.                        
        PERFORM bdc_insert USING 'LT01'.           
        PERFORM close_group.                       
    ENDIF.
    Regards,
    Sookshma

  • I have reset my iphone 5c and now has apple logo on the screen. I have tried holding home and lock buttons for 10 seconds, but to no avail. How do i sort this please ?

    I have reset my iphone 5c and now it has the apple logo on the screen.  Nothing is happening, apart from the screen going off for a few seconds, only to go back to black screen and white apple log.  I have tried holding home and lock buttons for 10 seconds, but to no avail.  I did a reset on settings as the IOS 8 was just slowing down my phone horrendously.   How do i sort this please ?

    Hi MartinH78,
    If your iPhone isn't responding or won't start up past the Apple logo, you may find the troubleshooting steps outlined in the following article helpful:
    iOS: Not responding or does not turn on
    Regards,
    - Brenden

  • TS1492 When I go to iTunes and then check for updates. I can not do this action due to the fact iTunes will not connect to the internet although the internet is working just fine, what do I do to fix this issue? Apparently I am currently using iTunes 7.0.

    When I go to iTunes and then check for updates. I can not do this action due to the fact iTunes will not connect to the internet although the internet is working just fine, what do I do to fix this issue? Apparently I am currently using iTunes 7.0.

    If you're really using iTunes 7.0 you are very far behind the current version - maybe it is trying to connect to a decomissioned server.  In fact I am kind of surprised it will run on a Macbook Air.  Are you sure you are running iTunes 7?

  • I cant update my iphone and i tried going on my pc on itunes and clicking check for update button but it says that "itunes could not contact the iphone software update server because you are not connected to the internet".plz help

    i cant update my iphone and i tried going on my pc on itunes and clicking check for update button but it says that "itunes could not contact the iphone software update server because you are not connected to the internet". But i checked my internet on both my pc and iphone and tried again but it still says the same thing. plzz plzz help

    Were you definitely connected to the internet at the time? If you don't have iOS 5 on your iPhone then the only way to update it would be via iTunes, once updated to the latest version of iOS you'll be able to update your iPhone without connecting to iTunes "over-the-air".
    Before updating however it goes without saying to Backup your iPhone, this should happen by default upon connecting your iPhone to iTunes.
    Regards,
    Steve

  • I dropped my iPhone 5c and it wont turn on but its constantly vibrating. I have tried holding the home and lock screen for a long time but nothing has happened. How can I fix this?

    I dropped my iPhone 5c and it wont turn on but its constantly vibrating. I have tried holding the home and lock screen for a long time but nothing has happened. How can I fix this?

    You make an appointment at the genius bar of your local Apple Store and get it serviced/replaced. You broke it. If you can't even force a reboot, there's nothing much more you can do.

  • For those who run Windows 8 with bootcamp: Do you update windows 8, with windows update? I have the latest bootcamp drivers, and never checked for updates on windows. Do you normally update windows 8?

    Windows 8 has been running very well after installing it with bootcamp and its latest drivers.
    I just have never updated Windows 8 itself, (windows has never checked for updates), and just has been
    using it bare. Do you update windows 8 to the latest updates with windows 8, and have any problems
    with the updates? Just curious before I start updating it for once.

    You have to update Windows to the latest version with Windows Update and keep it updated, because this is a matter of security. Microsoft provides a lot of security updates and you have to install them even if you have got an antivirus. Then you can find other updates, and if you want to install Windows 8.1, just install all updates with Windows Update, and then go to the Windows Store and download Windows 8.1.
    Apple says that Windows 8.1 is not supported by Boot Camp, but people say it works without any problem with the most recent drivers, so I do not find any risk after upgrading to Windows 8.1.

  • After 3.6.10 all add-ons disappeared and a search for updates showed none needed. How do I get them back?

    I am running on a Mac OSX 10.6.4. After updating Firefox to 3.6.10, a few add-on disappeared. Specifically, Delicious, 1Password, Stumble ON and Buckts. I looked for updates and none were available. I've run through the view menu and preferences but can't find an option to restore these functions. Do all these add-ons need to be updated to be compatible with 3.6.10 or is there something in the update that wiped out these views.

    Add-ons that worked in 3.6.9 and earlier versions of 3.6 should also work in 3.6.10.
    The first thing I would try is to delete the files that store details of installed add-ons. If one of those files is corrupt it can cause problems with add-ons not being listed. For details of how to do that see the corrupt extension files section of the [[Unable to install add-ons#Corrupt extension files|unable to install add-ons]] article.

  • Screwed up and deleted playlists for updating

    I cannot update my mini. I had too many songs and I guess it created a playlist of randomly selected songs. I thought by unchecking songs off my library I could select my songs I wanted. I deleted my previous playlists. Now my mini won’t update. It says the playlists selected for updating no longer exist. How do I fix it so I can update again? Thanks

    Cool. Thank you so much. That link did help and I saved it in case I screw up again or one of my friends screw up. LOL!
    Actually I didn't need it. But I needed your advice to try it out.
    What solved my problem was to install a new set of songs off my laptop. When I did that, it gave me a message saying do I want to relace all songs with ones on this computer or something like that. I said yes and got songs from my laptop on the iPod. Then this morning after getting your advice and link I went to the desk top. When I loaded the mini on to the Desk top it asked if I wanted to dump all the songs on the iPod and replace them with ones on this computer? I said yes and it said there were too many songs and would I like it to select a ramdon group of songs and it created a new folder labeled "flpaa's iPod selections". So it's working fine now. Thanks so much for your help. Take one gold star for your help.

  • Setting visible lines and blank rows for all users

    At Item Level for Shopping Cart, Confirmation and Invoice Creation there are settings for Number of Visible Rows and Number of Blank Lines (In Settings/Advanced Settings).
    How can this be changed for all users?

    Hi
    This is a user specific settings to be performed. in SRM 7.0
    Please prepare a document and educate the user to do. This is  the best solution
    Second Solution
    In Setting tabs there are two tabs -Basic Setting and Advance Setting
    check the webdynpro components and hide this for all users
    Regards
    G.Ganesh Kumar

  • Explicit Lock on for Update Table

    If I want to perform explicit lock acquiring on updating all records in “customer” table with “state” equals to “CA”. What command should I run?

    Hi,
    Refer to following ppt.
    http://www.indiana.edu/~dbateam/Documents/oracle_locking.ppt#260,5,Oracle Isolation Levels
    You can get to know the things.
    - Pavan Kumar N

  • So i charged my phone, plugged it into the computer and wall , and i've held the home and lock screen for several seconds and it still wont turn on what's wrong?

    My iPhone will not turn on at all , i've tried about everything such as : Plugging it into my computer , plugging it into the wall , holdinq the home and power button for several secondss and i've on ly had it for about 6 months and i took good care of it , what could be wrong ? Please help anyone .

    http://support.apple.com/kb/TS3281

  • Lock rows in update masks

    a simple, wizard-generated application does not prevent concurrent updates:
    Two separate sessions may both update the same row, and there is no warning for the front-end user.
    Only after the second update, the second user gets a "ORA-20001: Current version of data in database has changed since user initiated update".
    Is there a way to implement a row locking which would prevent the second user from entering the row update while it is locked?
    (I assume, this is a general problem in Web apps)
    Regards, Thomas

    hi ,
    did you find the solution ?
    solo

Maybe you are looking for

  • NullPoniter Exception while Adding in JComboBox

    Hi All, My application is a Applet - EJB based and Server is sending Serialized Objects to add in to the JCOMBOBOX object. I have the following Exception coming up after a few iteratons ( 200 ) of opening up the screen and closing it which I am doing

  • Why did my Apple logo turn blue at start up?

    At start up, the Apple logo turned blue (originally gray).  The outline of the logo also became pixelated, containing the colors red, green, yellow, etc. I also have this problem where whenever I am using an application (during the first hour after s

  • Insert  Line item in Po

    Hi Guru's, I need to insert new line item into po if the material entered is BOM material , my requirment like this , if the user creates the po with BOM material then i need insert all the inside components as line item in that po, please suggest me

  • First Generation ipod

    Yes, i am buying a first generation ipod. it said that it is connected though firewire "Specificly" for MAC but if my PC has a firewire port.... will it work?

  • Path to Resource

    I am trying to load a script saved in the Resources folder of an app that I created using the following command: set enclosedList to load script ((path to resource) as text) & "enclosedList.scpt" When I do this I get the following error: "Can't make