How can a ROLLBACK occur on SELECT

Posted on 2011-10-07
Last Modified: 2012-06-27

We had an instance in one of our test regions where a user ran a very badly written SELECT query  on 3 very large tables. The query was run from IBM DB2 connect. At some point when the query was chewing up all resources on the AS400 server we decided to do a end the job that was running the DB2 connect. The job has been showing us a ROLLBACK since then. Why would there be any ROLLBACK when the query that the user was running was a SELECT query?

Any pointers?

Question by:bhagatali
    LVL 37

    Accepted Solution

    it needs to free up all the locks...

    Author Comment

    Forgive my ignorance, but when reading from a table, i assume it puts up shared locks on the records that are selected. I am familiar with the concept of lock escalation but i thought it applied mainly to updates/inserts. Do lock escalation (from row level to table level) happen even when reads are being performed?
    LVL 18

    Expert Comment


    With badly written queries over large tables, the optimizer sometimes creates "temporary" tables and indexes that it uses to execute the query.

    If you kill the query, it has to rollback those obects, too.

    LVL 34

    Expert Comment

    by:Gary Patterson
    "Rollback" is the name of the state a db job goes into when an SQL step running under commitment control ends in error. Depending on how you terminated the db2 connect job, it is possible that the server is hung in a state where it is waitng for a response from the client.

    Jobs running under commitment control go through a more complex recovery process, and it is possible that there can be more than one SQL statement within a transaction that s being rolled back.

    Eventually it will probably time out. Sometimes the job log of the hung job will provide clues.

    If the rollback job is not consuming resources, then it may just be hung. If so, you can also try to force the job to shutdown by ending it directly using wrkactjob option 4 or endjob. Assuming this is a qzdasoinit/qzdassinit job?

    If this happens frequently, you need to make sure you are current on database ptfs.
    LVL 14

    Expert Comment

    you may need to include the


    the the sql select statement otherwise dependant on the environment it may try to obtain some locks.


    select  * from my file FOR READY ONLY



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
    Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now