• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 566
  • Last Modified:

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.
0
bhagatali
Asked:
bhagatali
1 Solution
 
momi_sabagCommented:
it needs to free up all the locks...
0
 
bhagataliAuthor Commented:
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?
0
 
Dave FordSoftware Developer / Database AdministratorCommented:

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
0
 
Gary PattersonVP Technology / Senior Consultant Commented:
"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.
0
 
daveslaterCommented:
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

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now