Avatar of bhagatali
bhagataliFlag for United States of America

asked on 

How can a ROLLBACK occur on SELECT

Hi,

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?

Regards
Ali.
IBM System iDB2

Avatar of undefined
Last Comment
daveslater
ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of bhagatali
bhagatali
Flag of United States of America image

ASKER

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?
Avatar of Member_2_2484401

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.

HTH,
DaveSlash
"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.
Avatar of daveslater
daveslater
Flag of United States of America image

Hi
you may need to include the

FOR READY ONLY

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

ie

select  * from my file FOR READY ONLY

Dave

DB2
DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.

6K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo