Same update in concurrent transactions

same update statement in concurrent transactions, update 10 records
update test set id=id where rownum<10
first transaction update 1,2,3,4,5,6,7,8,9,10
second transaction update 10,9,8,7,6,5,4,3,2,1
This may lead to deadlock?
That will not happen under normal circumstances
but row migration

872390 wrote:
same update statement in concurrent transactions, update 10 records
update test set id=id where rownum<10
first transaction update 1,2,3,4,5,6,7,8,9,10
second transaction update 10,9,8,7,6,5,4,3,2,1
This may lead to deadlock?
That will not happen under normal circumstances
but row migrationrefer the link:-http://www.orafaq.com/node/854

Similar Messages

  • Concurrent transactions

    Hi, please consider a plain old Java (not EJBs) application for a book store.
    The application offer 3 operations:
    1. Add new book (Store the book info in the DB).
    2. Remove book (remove the book info from the DB).
    3. Modify book (update the book info in the DB).
    The system must support multiple users doing requests at the same time, thus the application must support concurrent transactions.
    The ANSI/ISO SQL standard defines the four isolation levels: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READS, SERIALIZABLE. Each level provides certain degree of isolation, the greatest isolation level is SERIALIZABLE but I've readed from several sources that it's not convenient to use this level because it causes a heavy impact in the performance and thus suggests to use READ COMMITTED.
    As far I know, the first three isolation levels don't provide perfect isolation: they allow ugly problems to appear like dirty reads, unrepeatable reads and phantom reads.
    What should I do to provide isolation to my system while using READ COMMITTED?
    I think that lots of people have faced this problem over years, and the question is: Are there some "common" or "standard" techniques to solve this?
    In other words, what is the correct approach to solve this?
    Thank you very much for the help.

    I have written two programs to test the situation.
    The first program uses JDBC.
    The second program uses hibernate.
    Both programs show the same result: The final copies count is wrong. The "lost updates" problem is occurring in both.
    Preconditions:
    Create a database.
    Create the table BOOK: create table BOOK (BOOK_ID INTEGER, TITLE VARCHAR(30), COPIES INTEGER, PRIMARY KEY(BOOK_ID))
    Insert in the table the row with BOOK_ID = 1, Title = "The Java Patterns", COPIES = 7:
    Below is the code for the JDBC test.
    public class LostUpdatesTest3 {
         private static CyclicBarrier barrier = null;
         public static void main(String[] args) throws Exception {
              Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
              int numOfThreads = 5;
              Thread[] threads = new Thread[numOfThreads];          
              barrier = new CyclicBarrier(numOfThreads);
              for (int i = 0; i < numOfThreads; i++) {
                   threads[i] = new MyTransaction();
                   threads.setName("thread " + i);
                   threads[i].start();
              for (Thread thread : threads) {
                   thread.join();
         private static class MyTransaction extends Thread {
              public void run() {
                   Connection con = null;
                   try {
                        con = DriverManager.getConnection(
                                  "jdbc:derby:d:/pruebas/jdbc1db;create=true", "root", "root");
                        con.setAutoCommit(false);
                        Statement statement = con.createStatement();
                        ResultSet resultSet = statement.executeQuery("SELECT * FROM BOOK");
                        resultSet.next();
              int id = resultSet.getInt("BOOK_ID");
              int copies = resultSet.getInt("COPIES");
                        barrier.await();
                        PreparedStatement preparedStatement = con.prepareStatement(
                        "UPDATE BOOK SET COPIES = ? WHERE BOOK_ID = ?");
                        preparedStatement.setInt(1, copies - 1);
                        preparedStatement.setInt(2, id);
                        preparedStatement.executeUpdate();
                        con.commit();
                        statement.close();
                        preparedStatement.close();
                        con.close();
                   } catch (Exception e) {
                        e.printStackTrace();
    This test creates 5 threads and starts them. Each thread runs a transaction to reduce 1 to the copies count.
    At the end of the test, the book have COPIES = 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Concurrent transactions problem- Can anybody help?- very urgent

    I have tested our application for multiple transactions i.e. concurrent transactions between two servers with IIS and Tomcat environment. We found some unexpected result and which is irrespective of the data (size ranging from 10 bytes to 10 kb, 50kb 70kb etc) sending across the servers on
    I was testing with 5 transactions (with data size of 13 bytes) from one machine (server1) i.e 5 windows of internet explorer. When I clicked on all the five, one after another quickly, I found that 4 transactions got success and one browser went to hang mode.
    Second time when I clicked on it, I found that 3 transactions got success, 1 in hang mode and 1 failed.
    We traced the exception at the point where it fails. Everytime it fails while reading the response back from the other end through InputStreamBuffer. The block in which it fails is
    Please follow the piece of code which i have written
    //reading response from the destination decrypt url,
    //which is also encrypted and signed
    //sending the same to caller of encrypt
    String data="";
    int end=0;
    char c[]=new char[4*1024];
    BufferedReader buf=null;
    //reading data in a chunks of data
    try
    inr=new InputStreamReader(connection.getInputStream());
    buf=new BufferedReader(inr,12*1024);
    while ((end=buf.read(c))!=-1)
    data=new StringBuffer(data).append(c,0,end).toString();
    catch(OutOfMemoryError e)
    System.out.println("Out of memory errror"+e.getMessage());
    try
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
    return;
    catch(Exception e1)
    return;
    catch(Exception e1)
    System.out.println("Failure in reading response"+e1.getMessage());
    try
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
    return;
    catch(Exception e2)
    return;
    finally
    try
    if(inr!=null)
    inr.close();
    if(buf!=null)
    buf.close();
    if (connection != null)
    connection.disconnect();
    catch(Exception e)
    System.out.println("Error in closing connection"+e.getMessage());
    Here the connection get disconnected and throws the following exceptions at difterent time of testing in failure case.
    1. Failure in reading response JVM_recv in socket input stream read (code=10004)
    Error in closing connection Socket closed
    2. Null pointer exception.
    Could you please tell us what would be the reasons for the above exceptions or failure and how to rectify or handle it.
    Thanks & Regards
    Gabriel

    - First, do not use BufferedReader.
    Use InputStream.read(byte[]) and make them to an String.
    If does not help use another stable version of TOMCAT
    on the same way.
    Also it is better to read the data over the Servlet API
    methods not over the IO streams.
    e.g. request.getParameter("XXX")
    - Do not close the socket connection in TOMCAT.
    TOMCAT themselves close the connection for you.
    Use the flush() method for getting the data faster.

  • Update termination in Transaction ME9F

    Hello MM Guru’s,
    I would like to inform you that we are observing update termination in transaction ME9F for a particular user repeatedly in production environment.
    Error in Functional Module: RV_MESSAGE_UPDATE
    Error Message: WHT type Z4 missing in vendor master XXXXXXXX
    When I check in vendor master data Indicator for withholding tax type Z4 already maintained.
    It was strange why when users execute transaction ME9F the above updates terminate happens in the system.
    I got a similar issue earlier where at that time Indicator for withholding tax type not maintained in vendor master data and I have informed business to maintain and re execute the transaction ME9F.
    Request you to help me on this issue as I said this is a repeated one which is occurring for a particular user and I need to fix it by taking your valuable input.
    Revert back in case you need any information required from my end.
    Cheers,
    Kumar S

    Hello Bijay
    I was asking you about my analysis (2 different users access ME9F for the same PO) done along with ABAPer whether its correct or not.
    In your earlier response you have not responded to my analysis instead you are replying me that experts cant access my system.
    I very well understand that our Experts cant access my system but they are always helping me for my all issues with their valuable input.
    We just wanted to know whether we are deviating from the issue in this case.
    I have also checked what other experts like Jurgen/AKPT & Mallinath suggested me and the analysis given below,
    To inform experts that we never use custom print program and we are using standard SAPFM06P print program.But the layout is custom according to our business requirement.
    Let me know still you need any clarification from my end.
    Regards,
    Kumar.S

  • How to update the FB01L transaction using the FM  bapi_acc_document_post

    Hi All,
            How to update the FB01L transaction using the bapi_acc_document_post but there is no ledger group field in the bapi function module.
    Please help me how to do it.

    hi,
    use batch input method for the same.
    check this.
    [https://forums.sdn.sap.com/click.jspa?searchID=19107237&messageID=884744]

  • Can we rollback the update query using Transaction?

    Can we rollback the Update query by writing the update query with in the transaction, as i am implementing different update queries, sometimes I am mistakenly updating the table without where criteria, which is messing up the table. Is there anyway where
    we can write the update query within a transaction and rollback that particular update query which I am writing. I do have a backup table, but that wont be useful because we are doing lot of updates in a span of minutes. I researches about Apex Sql logs too,
    but we do not have access to download such tools. So, can anyone give me a good solution for this?

    Sure, if you use transaction like this
    begin transaction
    update 1
    update 2
    rollback transaction
    both updates will be rollbacked.
    If you want to always be sure about rows you're about to change, always first try with SELECT statement and put each individual UPDATE into separate transaction with rollback at the end, e.g.
    begin transaction
       select ... where some condition
       update . where same condition
       select ... where same condition to verify update
    rollback transaction
    If your last select showed correct info, change ROLLBACK into COMMIT and re-run that script again to perform the actual update.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Add new mandatory column without killing concurrent transactions

    I know of several approaches to this problem, but as the table in question is key to my organisation, I'd quite like to get this right first time!
    I need to add a 1 character column to a large (approx 1 million rows, approx 100 cols) table which also happens to be central to our database (contains client details). The table is involved in the majority of transactions on our database, 24/7 so I need to find the method with the least impact on concurrent transactions.
    We use mod_plsql for our applications, and a previous attempt (by another developer) caused all web pages to become unresponsive, followed by a database shutdown.
    Any advice?

    Just a note that I ended up writing a pl/sql script which used a select for update cursor to update the non-locked rows, and stored any locked rowids in an associative array. It then looped round the array trying to update these rows until they were all done. Did the trick. DBA wasn't keen or the redefinition package when he saw what it did!
    thanks,
    M

  • Problem in executing update after rollback transaction

    Hi all
    I am using type4 driver oracle9i ,Stateless session Beans CMP. Problem is: after doing rollback i am trying to execute an update query on same id which was rolled back.System is not able to do the same.
    Manmeet

    got the solution.
    cannot rollback and do update in a transaction.

  • Reg: Header text updation in VL02n transaction

    Hi Experts,
    i have one requirement in return delivery.
    I am executing one customizing trasaction, and it displays screen.
    In that screen i am editing the fileds and when i click on the save button i need to update in delivery transaction header texts (VL02n transaction goto header texts).

    Hi,
    Use the SAVE-TEXT FM as below.
      CALL FUNCTION 'SAVE_TEXT'
           EXPORTING
                HEADER    = LS_THEAD
           IMPORTING
                NEWHEADER = LS_THEAD
           TABLES
                LINES     = TLINETAB
           EXCEPTIONS
                ID        = 1
                LANGUAGE  = 2
                NAME      = 3
                OBJECT    = 4
                OTHERS    = 5.
      IF SY-SUBRC = 0.
    Where LS_THEAD, CONTAINS:
                                            TDOBJECT                                             VBBK
                                            TDNAME                                             00999999(Your delivery no)
                                            TDID                                                         Z950
                                            TDSPRAS                                             E.
    You can find this details, when you go to the transaction(VL02N) and enter some text and do the debug on  SAVE_TEXT FM, then get the values it uses to save the text, use the same in you program.
    Hope this helps,
    Cheers,
    Srini.

  • Concurrent transactions in servlets using HttpConnectionURL class

    I have tested our application for multiple transactions i.e. concurrent transactions between two servers with IIS and Tomcat environment. We found some unexpected result and which is irrespective of the data (size ranging from 10 bytes to 10 kb, 50kb 70kb etc) sending across the servers on
    I was testing with 5 transactions (with data size of 13 bytes) from one machine (server1) i.e 5 windows of internet explorer. When I clicked on all the five, one after another quickly, I found that 4 transactions got success and one browser went to hang mode.
    Second time when I clicked on it, I found that 3 transactions got success, 1 in hang mode and 1 failed.
    We traced the exception at the point where it fails. Everytime it fails while reading the response back from the other end through InputStreamBuffer. The block in which it fails is
    Please follow the piece of code which i have written
    //reading response from the destination decrypt url,
    //which is also encrypted and signed
    //sending the same to caller of encrypt
    String data="";
    int end=0;
    char c[]=new char[4*1024];
    BufferedReader buf=null;
    //reading data in a chunks of data     
    try
         inr=new InputStreamReader(connection.getInputStream());
         buf=new BufferedReader(inr,12*1024);          
         while ((end=buf.read(c))!=-1)
              data=new StringBuffer(data).append(c,0,end).toString();
    catch(OutOfMemoryError e)
         System.out.println("Out of memory errror"+e.getMessage());
         try
              response.sendError(HttpServletResponse.SC_NOT_FOUND);
              return;
         catch(Exception e1)
              return;
    catch(Exception e1)
         System.out.println("Failure in reading response"+e1.getMessage());
         try
              response.sendError(HttpServletResponse.SC_NOT_FOUND);
              return;
         catch(Exception e2)
              return;
    finally
         try
              if(inr!=null)
                   inr.close();
              if(buf!=null)
                   buf.close();
              if (connection != null)
                   connection.disconnect();     
         catch(Exception e)
              System.out.println("Error in closing connection"+e.getMessage());
    Here the connection get disconnected and throws the following exceptions at difterent time of testing in failure case.
    1. Failure in reading response JVM_recv in socket input stream read (code=10004)
    Error in closing connection Socket closed
    2. Null pointer exception.
    Could you please tell us what would be the reasons for the above exceptions or failure and how to rectify or handle it.
    Thanks & Regards
    Gabriel

    Can anybody look into it , this very urgent
    thanks
    Gabriel

  • JMS Cache updates in existing transactions

    We have two application instances running, with synchronization over JMS. In the following scenario what will be the outome?
    - AppInstance1 does changes to Object1 and commits. These changes are sent to the JMS queue.
    - AppInstance2 is in the middle of one transaction when it recieves the cache updates. The current transaction include Object1 (which updates are received for).
    Does the transaction in Instance2 get aborted upon receiving the cache sync or are the mechanisms at work in TopLink smart enough to merge the non conflicting fields?
    Thanks,
    Anders,

    This depends on your locking mechanism and has little to do with cache-synch. Cache synchronization does not replace the requirement for a locking mechanism.
    If you are using no locking, then no matter if you have a single server, multiple servers with or without cache synch, then there is the potential that concurrent transactions can overwrite each others data.
    If you are using optimistic locking, then no matter if you have a single server, multiple servers with or without cache synch, your second transaction will get an optimistic lock error and its transaction will be rolled-back.
    If you are using pessimistic locking, then there is not much point in using cache synch as you will be accessing the database anyway. The second transaction will block on its read of the object until the first transaction completes, or throw an error on read if using no_wait.
    The benefit that cache synchronization provides it that because changes are synchronized between servers the likely-hood of getting an optimistic lock exception is greatly reduced. It can also be used with infrequently updated objects that do not use any locking, or object to which locking is not an issue.

  • How 'Assignment' is updated using VL02N transaction ?

    Hi Experts,
    I want to know how and where in the program SAPMV50A, the 'assignment' field is updated when  I post a GI document using VL02N transaction.
    The filed for assignment is ZUONR of BSEG table. I want to know how the ZUONR field is updated while VL02N transaction is used to post a GI document.
    Please help me asap.
    Thanks & regards
    Sanglap Ghosh
    Edited by: sanglap_ghosh581 on Mar 10, 2010 10:18 AM
    Edited by: sanglap_ghosh581 on Mar 10, 2010 10:20 AM

    Did you find a solution for this? I have the same requirement.

  • Application crashes nearing 28 concurrent transactions

    Its been a while folks.... I used to post and answer allot
    here back in the day when i was coding in CF daily.
    Here is the problem... more details will follow when I get
    them. I was tasked by my director to look into a problem for an
    application on the network. NOTE: I know longer work in CF I
    haven't used it since I got certified on version 5.0 ( I knew I
    should have pulled my CF experience off my resume
    Anyway this is what I have so far, its not much but I was
    hoping someone out there has seen this and it a known
    infrastructure problem.
    This is what I got:
    "the issue is when they get up to 28 concurrent transactions,
    the application crashes"
    They are using ColdFusion Ver 7 Enterprise Edition
    (7.0.2.142559).
    Webservers ( 3 of them )
    HP Proliant BL25 G1
    4GB Ram 67GB Disk (via 2 disks mirrored) 2 dual-core 2.20GHz
    AMD processors
    Windows 2000 SP4
    IIS 5
    ColdFusion Ver 7 Enterprise Edition ( 7.0.2.142559 )
    Sun Java 1.4.2_13
    Course Content Server
    2GB Ram 4 x 3.2GHz Intel CPU
    Windows 2000 SP4
    IIS 5
    Apache Tomcat 4.1
    DB Server ( active/passive cluster)
    HP Proliant BL45P G1
    8GB Ram 67GB Disk (via 2 disks mirrored) 4 dual-core 2.2GHz
    AMD processors
    Windows 2003 SP1 Enterprise Edition
    Microsoft SQL 2000 Server Enterprise Edition SP4

    Thanks for your reply I am working on getting the log once I
    get access to the server Admin. They set the system to monitor
    everything and they are trying to replicate the problem to generate
    some type of useful log.
    I did have a call with the Client and they indicated that
    under large volumes.. 1/3 web servers hangs and does not take
    requests. The other 2 work fine and and CF runs as designed. All
    run IIS 5

  • [Oracle 10g] How to show concurrent transactions during a period?

    Hello all,
    I used Oracle 10g database
    I try to select the number of concurrent transactions during a period.
    I know how to select the number of transactions executed in one day, but i want to know the concurrent transactions.
    Can you help me ?
    Thanks in advance
    Regards
    Mathieu

    Which transactions do you wish to track?
    Are you referring to transactions that occur against a specific set of tables or all transactions against a schema and/or database instance?

  • Since downloading ios8 to my I pad mini I am unable to sync movies, however I can sync them on my I phone 5s with same update? How can I change this?

    Since downloading ios8 to my I pad mini I am unable to sync movies, however I can sync them on my I phone 5s with same update? How can I change this?

    Thanks - that helped. But when I tried to sync all my photo folders to the I pad 2, I tunes would add some but not all of the ones that were marked to sync, end the sync, then the I pad 2 would hang with the wheel turning, saying it was still syncing photos, and it would not end and the remaining folders of photos never appeared. I finally had to sync and re-sync over and over by adding one folder of photos at a time, then another and another.

Maybe you are looking for

  • Error deploying BPEL process on SOA Suite 11g

    Hi, We have installed SOA Suite 11g (Weblogic 10.3.1.0) on Windows. I'm trying to deploy a simple BPEL Process on this SOA Suite through JDeveloper 11.1.1.1.0 Studio. However I'm getting the following error: [10:29:08 AM] Preparing to send HTTP reque

  • Safari 4.0.3 crashes while opening website

    Safari 4.0.3 update on OSX 10.4.11 PPC G5 dual 2.3 6GB RAM 169GB of free HD space. Safari crashes down when opening certain sites. It also downloads the files called b.ashx at time. I tried everything what I know and have read in this forum: re-insta

  • Objects in Master slides staying infront

    Hi I'm wondering if there is an option within keynote to allow objects in master slides to appear in front of objects in slides that that master is applied to. Hope this makes sense!!

  • 10.4.8 worst update I've ever had from Apple.

    I'm pretty much a Mac expert, never had a problem with a update in 15 some odd years but 10.4.8 has a lot of glitches. Main problem is airport related on all 6 macs, G4, G5 and intel machines. I hope Apple fixes it's errors very soon.

  • Filter not working in case insensitive mode

    Hi, I have created a Dashboard using Oracle BAM (version 11.1.1.4.0). The Dashboard contains some filters to filter out the data visible in the report. If I give ALL or All in the filter and click on Go. I can see the data in report. but it does not