How and when the database release a row lock?

Dear experts,
We are using the following statement to obtain a row lock in a table in the database(ORACLE of course),
SELECT * FROM {TABLE_NAME} WHERE ID = 1 for update
and if we succeed grabbing the row lock we will continue to issue a update statement every 30 seconds to preserve the lock as far as possible.
here is the update statement to preserve the lock,
UPDATE {TABLE_NAME} SET time = ? WHERE ID = 1.
As you see more longer we keep holding the row lock , more update statements are submitted in the pending transaction.
In normal case our application can grab the exclusive row lock and works for a long time,however sometimes a connection reset exception is thrown
and our application will close the connection(I assume the pending transaction will be rolled back by the database) and exit the JVM.
Since other applications will keep trying to grab the same row lock to become the master role,
we expect one of them can succeed but they are all failed because the database has not released the row lock as expected.
Can someone explain more details about how and when the row lock can get released in our use case?
Thanks,
SuoNayi
Edited by: SuoNayi on 2013-5-30 上午8:12

Hm. Is this part of an XA transaction by any chance? I know that Oracle maintains separate bookkeeping for such transactions which can cause rows to stay 'locked' even when the regular DBA views will indicate there is no user currently locking the record at all. I have no idea about the actual details and what you need to do to clean up such a situation, that is something a DBA should know and do.
If not... well this is more of a question for people who know the DBMS, which makes it a target for the Oracle DBMS forums. Java developers don't tend to have DBA-level knowledge of the database, you should ask the question where you have more chance of people with expertise answering stuff:
General Database Discussions

Similar Messages

  • How and when the table will go STALE ?

    Hi,
    I want to check how and when a table will be marked as STALE.
    I have done following steps
    ---- Created a table --------------------
    SQL> create table t1 (id number, name varchar2(100)) ;
    Table created.
    ---- Inserted decent amount of data --------------
    SQL> declare v1 number; begin for i in 1..25 loop
    2 insert into t1 select object_id, object_name from all_objects ; commit; end loop;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> select table_name, status, num_rows, last_analyzed, monitoring from user_tables where table_name='T1';
    TABLE_NAME STATUS NUM_ROWS LAST_ANAL MON
    T1 VALID YES
    ---- Gather stats -----------------
    SQL> exec dbms_stats.gather_table_stats( user, 'T1', METHOD_OPT => 'FOR ALL COLUMNS SIZE 1');
    PL/SQL procedure successfully completed.
    SQL> select table_name, status, num_rows, last_analyzed, monitoring from user_tables where table_name='T1';
    TABLE_NAME STATUS NUM_ROWS LAST_ANAL MON
    T1 VALID 115544 18-JAN-08 YES
    ---- Insert more data ---------------------------
    SQL> declare v1 number; begin for i in 1..25 loop
    2 insert into t1 select object_id, object_name from all_objects ; commit; end loop;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    Now, after I have analyzed the table and get the stats in, I loaded good amount of data. So, in theory, this table should be marked as STALE.
    Where can I check if this table has been marked STALE? when ?
    Please guide.
    Thanks

    You need to read that manual with more caution. It has all info you need.
    1. Table modification info stays in shared pool and flushed into dictionary by Oracle automatically. You can explicity do it by calling dbms_stats.flush_database_monitoring_info.
    2. dba_tab_modifications view = How many DML are applied to target table?
    dba_tab_statistics.stale_stats = Is statistics stale?
    3. When you call dbms_stats.gather... familiy, Oracle flushed the stale info to disk. You gnerally don't need to care about that.
    4. Statistics is considered to be stale, when the change is over 10% of current rows.
    (As of 11g, this value can be customized per objects. Cool feature)
    create table t_stat(id int);
    insert into t_stat select rownum from all_objects where rownum <= 100;
    commit;
    exec dbms_stats.gather_table_stats(user, 'T_STAT');
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    No row selected
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    NO
    insert into t_stat select rownum from all_objects where rownum <= 20;
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    No rows selected <-- Oops
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    NO  <-- Oops
    exec dbms_stats.flush_database_monitoring_info;
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    TABLE_OWNER     TABLE_NAME     PARTITION_NAME     SUBPARTITION_NAME     INSERTS     UPDATES     DELETES     TIMESTAMP     TRUNCATED     DROP_SEGMENTS
    UKJA     T_STAT               20     0     0     2008-01-18 PM 11:30:19     NO     0
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    YES

  • How and when the realDelete method gets called for a custom adapter?

    Hi,
    I am a newbie in sun identity manager and is in the process of writing a custom adapter for documentum resource.
    While I am successful in creating the resource,then provisioning the resource to an user(i.e creating an account of the user on documentum ) updating the user through idm I am not being able to deprovision the resource.
    Actually in the trace I am not seeing the realDelete method getting called anywhere,but I am sure if it gets called it would do its designated job bcos as a standalone code it's working.
    Does this mean I am not properly doing deprovisioning in sun-idm?
    What method I am employing is in the assignment list of the user,i am putting the resource from assigned to unassigned side(i.e right to left side) just as in case of provisioning I have put it from left to right.
    Is it the standard way of deprovisioning or am I missing something here?
    Any sort of help would be highly appreciated.
    Thanks
    anjan

    You need to read that manual with more caution. It has all info you need.
    1. Table modification info stays in shared pool and flushed into dictionary by Oracle automatically. You can explicity do it by calling dbms_stats.flush_database_monitoring_info.
    2. dba_tab_modifications view = How many DML are applied to target table?
    dba_tab_statistics.stale_stats = Is statistics stale?
    3. When you call dbms_stats.gather... familiy, Oracle flushed the stale info to disk. You gnerally don't need to care about that.
    4. Statistics is considered to be stale, when the change is over 10% of current rows.
    (As of 11g, this value can be customized per objects. Cool feature)
    create table t_stat(id int);
    insert into t_stat select rownum from all_objects where rownum <= 100;
    commit;
    exec dbms_stats.gather_table_stats(user, 'T_STAT');
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    No row selected
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    NO
    insert into t_stat select rownum from all_objects where rownum <= 20;
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    No rows selected <-- Oops
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    NO  <-- Oops
    exec dbms_stats.flush_database_monitoring_info;
    select * from sys.dba_tab_modifications where table_name = 'T_STAT';
    TABLE_OWNER     TABLE_NAME     PARTITION_NAME     SUBPARTITION_NAME     INSERTS     UPDATES     DELETES     TIMESTAMP     TRUNCATED     DROP_SEGMENTS
    UKJA     T_STAT               20     0     0     2008-01-18 PM 11:30:19     NO     0
    select stale_stats from sys.dba_tab_statistics where table_name = 'T_STAT';
    YES

  • How to change the default password file's name and path when the database created?

    how to change the default password file's name and path when the database created?
    null

    Usage: orapwd file=<fname> password=<password> entries=<users>
    where
    file - name of password file (mand),
    password - password for SYS and INTERNAL (mand),
    entries - maximum number of distinct DBA and OPERs (opt),
    There are no spaces around the equal-to (=) character.

  • How to recover the database when some of the archive log file get deleted.

    I am facing a problem with Oracle database, which is related to archivelogs.
    Our development database is running in archivelog mode, but we don't have backups scheduled and have no recovery catalog.
    When the database was in running condition, disk got full, so some archivelogs were deleted manually.
    After this they restarted the DB, and now DB is not coming up. Errors are as follows:
    SQL> startup
    ORACLE instance started.
    Total System Global Area 1444383504 bytes
    Fixed Size 731920 bytes
    Variable Size 486539264 bytes
    Database Buffers 956301312 bytes
    Redo Buffers 811008 bytes
    Database mounted.
    ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
    SQL> alter database open resetlogs;
    alter database open resetlogs
    ERROR at line 1:
    ORA-01113: file 1 needs media recovery
    ORA-01110: data file 1: '/export/home/oracle/dev/ADVFRW/ADVFRW.system'
    SQL> recover datafile '/export/home/oracle/dev/ADVFRW/ADVFRW.system'
    ORA-00283: recovery session canceled due to errors
    ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
    SQL> recover database using backup controlfile;
    ORA-00279: change 215548705 generated at 09/02/2008 17:06:10 needed for thread
    1
    ORA-00289: suggestion :
    /export/home/oracle/dev/ADVFRW/ADVFRW.archivelog1/LOG_ADVFRW_1107_1.ARC
    ORA-00280: change 215548705 for thread 1 is in sequence #1107
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    /export/home/oracle/dev/ADVFRW/ADVFRW.archivelog1/LOG_ADVFRW_1107_1.ARC
    ORA-00308: cannot open archived log
    '/export/home/oracle/dev/ADVFRW/ADVFRW.archivelog1/LOG_ADVFRW_1107_1.ARC'
    ORA-27037: unable to obtain file status
    SVR4 Error: 2: No such file or directory
    Additional information: 3
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    CANCEL
    Media recovery cancelled.
    SQL>
    1. How to recover the database and bring it online
    Any help will be highly appreciated.
    With Regards
    Hemant Joshi
    Edited by: hem_Kec on Sep 7, 2008 9:07 AM

    Hi,
    Archive log files are the copies of redolog files.As redo log files are circularly overwritten,oracle generates archive log file of the corresponding redo logfiles being overwritten.So if you have a backup that dates back to 10 am in the morning and if your database creashed at 3 pm,you cannot use the redo log files alone as they have incomplete information.To completely recover the database upto 3 pm,you need archive log files generated between 10 am to 3 pm. In your case since you are missing one archive log file,you cannot perform complete recovery and hence would suffer data loss.

  • How to add a field to the selection screen and when the user enters ...

    hi all,
    can any one plesase send the code of how to add a field to seletiion screen and when the user enters in the field , it should be store in the database table , the table is MKPF and the field is BKTXT.  Thanks.

    Hi Kripa,
       If u r using PNP ldb then the screen u will get is the screen for that ldb and if u want to add some more fields then u define using selection-screen..as follows
    SELECTION-SCREEN BEGIN OF BLOCK mysel WITH FRAME TITLE text-111.
    PARAMETERS: n_in_en  RADIOBUTTON GROUP g1,
                q_ev  RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK mysel.
    SELECTION-SCREEN BEGIN OF BLOCK mysel1 WITH FRAME TITLE text-222.
    PARAMETERS: r_date TYPE sy-datum DEFAULT sy-datum.
    SELECTION-SCREEN END OF BLOCK mysel1.
    SELECTION-SCREEN BEGIN OF BLOCK mysel2 WITH FRAME TITLE text-333.
    PARAMETERS:f_ver(3) TYPE c DEFAULT 1,
               c_no(10) TYPE c DEFAULT '9D0161',
               u_id(15) TYPE c,
               password(15) TYPE c,
               r_email(30) TYPE c DEFAULT PARAMETERS: s_not TYPE c AS CHECKBOX.
    PARAMETERS:t_run TYPE c  AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK mysel2.
    SELECTION-SCREEN BEGIN OF BLOCK mysel3 WITH FRAME TITLE text-444.
    SELECTION-SCREEN BEGIN OF BLOCK mysel4 WITH FRAME TITLE text-555.
    PARAMETERS: p_ser  RADIOBUTTON GROUP g2,
    a_ser  RADIOBUTTON GROUP g2.
    SELECTION-SCREEN END OF BLOCK mysel4.
    SELECTION-SCREEN BEGIN OF BLOCK mysel5 WITH FRAME TITLE text-666.
    PARAMETERS:p_path TYPE string.
    SELECTION-SCREEN END OF BLOCK mysel5.
    SELECTION-SCREEN END OF BLOCK mysel3.
    u will get this additional screen after the screen of ldb.
    I hope this will help u..
    Thanks & Regards
    Ashu Singh.

  • How to specify the database file path when create FDM application

    Dear All,
    How to specify the database file path (MSSQL) when create FDM application?
    Right now, all data file are placed in the D:\ . I want to specify the database files (log and mdf file) in other place. How to do it?
    Thanks.

    Where is the highS2.xml located on the disk? If you add it to your project you should set its Build Action to Content and its Copy To Output Directory to Always in Visual Studio:
    Please remember to close your threads by marking helpful posts as answer once your issue has been solved and then start a new thread if you have a new question.

  • How can flex tell if  it's a mouseup event when the user releases the mouse button outside the flex application?

    how can flex tell if it's a mouseup event when the user
    releases the mouse button outside the flex application? Say for
    instance mousedown was done within a 500x500 embedded flex app but
    mouseup is outside or relased on the HTML background. One more
    thing, when we have something draggable, Flex doesn't execute the
    stopDrag() when the user releases the mouse button outside the
    embedded swf or fles app. Pls. help me with this. Thanks!

    I don't think the flex app can tell what happens outside the
    app. But it can detect when it leaves the app, so I have found the
    following line works fine inside initApp():
    this.stage.addEventListener(Event.MOUSE_LEAVE, yourFunction);
    and you have to:
    import flash.display.Stage;
    Doug

  • How to deal with the situation when the database change into ms-sqlserver ?

    Hi,dear all,
    How to deal with the situation when the database change into ms-sqlserver or other database?
    Now, i want to build a j2ee project with ORACLE ADF bc,but this project may be used in several diffrent databases for example oracle db,ms db,mysql and so on.however,if i have developer this project in jdeveloper and this project connection was config as a oracle database,and then,can this project be reused for other databases espasially including the model codes? if yes,how should i do?
    all who know how to resolve this,tell me pls,thanks.
    bruce Li,
    China
    Message was edited by:
    user526724

    Hi Paulbin,
    Do you want to supply a function-pointer to a DLL so it can call[back] your VI?  Here's how it can be done with .NET, though, that solution requires a C compiler.   A single "VI_to_function-reference" utility could handle all cases where the callback passes no parameters.  Maybe someday somebody will share that dll.
    Did you know that LabVIEW can use Events for some COM-signals change?  See pic.  (Note: DTR is not listed - - )
    Another question is another function's prototype is WORD SetTestType(WORD comHandle, bool type1, bool type2, bool type3),   I tried to use a boolean control and a Boolean to (0,1) node in labVIEW to pass parameters to CLF, I config the bool input value as U8(according to C++ bool type) and U32(according to WIN32 BOOL type), it dose not help, when I execute the VI, LabVIEW will be disappeare, it seems to be closed, I must start it again.
    Could someone has similar experience on this points?
    It's easy to crash LabVIEW misusing CLF - maybe there's another reason for the crash besides bool mis-match(?)  Do you know which "Calling convention" is required?  What type is comHandle? (where does comHandle come from?) 
    Cheers!
    Message Edited by tbd on 03-23-2007 09:34 PM
    Message Edited by tbd on 03-23-2007 09:35 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    evt.jpg ‏7 KB

  • I got the iPhone 4S and I use google calendar and when the Sprint salesperson set up my phone only 2 months of my calendar went on my phone. How do I get my whole calendar to sync on my phone?

    I got the iPhone 4s and i use google calendar and when the Sprint sales person set up my phone, only 2 months showed up on my iPhone. How do I sync all of google calendar to my iPhone!

    Settings/Mail,Contacts,Calendar - there's a setting for how far back to sync calendars.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • I emailed a PDF form and when the receiver opens it, the document has errors on it. How do I fix this problem?

    I emailed a PDF file and when the receiver opened it there were errors in the file. Words on the document appeared different and weren't what they were supposed to be. How do I fix this problem?

    What did the errors say? Can you post a copy of the pdf so we can test out. The presets embed the font, but might be a unicode issue, or one of the few fonts which are copyrighted and do not allow embedding.
    What application was the pdf was created from, what settings were used, and if you can outline the fonts. What font or font(s) are the ones reflowing?

  • How and when do applications get stored on iCloud? I play a game called injustice and it saves to iCloud but seems to do it randomly. I often lose the most recent game and it backs up to an old one. Can i do it manually? is there a way to check?

    when do games get saved? Can i do it manually? I often lose most recent game if i restore it from iCloud

    You'd need to ask the developer. How and when individual apps use iCloud is up to the developer of that particular app,

  • How and When Does the attribute VI_ATTR_VXI_TRIG_STATUS get initialized

    How and When  Does the attribute VI_ATTR_VXI_TRIG_STATUS get initialized. Do the actual trigger lines get measured or does the attribute get initialized to a default value when the vxi resource manager is executed?

    Hey whl6868,
    According to page 157 (or 3-135) of the manual (http://www.ni.com/pdf/manuals/370132c.pdf), there is no default value for VI_ATTR_VXI_TRIG_STATUS.  If Resman is returning valid values for it, then it must be actually reading the lines.  Else, I would only expect it to return valid values when you actually call the function yourself.
    Regards,
    David R
    Applications Engineer
    National Instruments

  • I've used iPhoto to import photos from my camera.HOW and WHEN can I safely disconnect my camera for the mac mini.

    I've connected my digital camera to my 2013 mac mini and used iPhoto to import photos from the camera.
    HOW and WHEN can I safely remove the camera please?

    Dismount the camera by clicking on the unmount icon on the right in the iPhoto source pane. Once it is unmounted remove it
    LN

Maybe you are looking for

  • Mail crashes when i wanted to send a mail

    I don't what happen, but i recently update my OS, and now when i want to send a mail from my app mail, it closed inmediatley, i obtain this information from the console, could you help me? Thanks a lot Process:         Mail [382] Path:            /Ap

  • Parsing XML with VBS at a Windows Server 2008 R2

    Hi my name is Marius, and I have a little problem with my vbs script. I use this script to parse an xml File if there are errors inside. In my old environment Windows Server 2003 it would work fine. Now I will run this script at a newer Server 2008 R

  • Replacing the "No rows returned" message in Portlets

    Hi all, How to remove (or replace) the default message that comes in each Portlet if the query doesnot return anything ? By default the Portlet shows the message "No rows returned" , how to customize it or remove it. Ayman

  • Installing Solaris 10 on Sunfire V120 via network boot from Linux

    I have been given a free SunFire V120 server loaded with and old copy of Solaris 9. The problem is that this server no longer has the internal DVD/CDRom drive any more. Google'd for finding a replacement CD-Rom drive show cost more than the SunFire V

  • Do I need to use standby database in begin backup mode to take the backup?

    Hi All, I have a 10g(10.2.0.4) primary database with standby on a solaris platform. I need to create another standby database for the same primary. I have stopped the recovery on existing standby database and started copying(os copy) the files from e