Re: Rollback
Posted in 1997
Topics: Storage & Space Management, Transactions, Locking & Isolation
Rick Ward wrote:
>
> 1) When Online detects a deadlock, does it automatically rollback the
> second transaction which will create the deadlock so that it can
> release the locks allowing the other process to continue, or does
> it expect the program to handle the error and issue the required
> rollback ? (For reference, if DB2 detects a deadlock it rolls back
> the transaction with the least amount of work to rollback).
It does the ROLLBACK automatically. As far as I know, it will ROLLBACK
the second transaction, not the one with least work to ROLLBACK.
> 2) Are there any SQL statements which will cause an automatic rollback
> within a transaction ? For example:
>
> BEGIN WORK
> SELECT * FROM table WHERE col1="x";
> UPDATE table2 SET col2="y" WHERE col1="burp";
> INSERT INTO logtab VALUES ("burp-done");> COMMIT WORK;
>
> If the insert failed because of, for example, lack of disk space,
> would Online rollback the transaction, or expect the program to
> handle the error ? I ask because it is obvious in the case of a lack
> of disk space that the transaction cannot complete, therefore a
> rollback by the engine would enable the locks held to be released
> earlier than the program code handling it.
No there are not. It is up to your code to handle errors like disk full.
Basically EVERY SQL command in your code should be followed by error
trapping code which handles the ROLLBACK.
Hope that helps,
--
Mark.
+------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group http://www.west.co.za |
| The Informix FAQ is at http://www.iiug.org |
|mailto:marks@west.co.za +-----------------------------------------+
|Tel: +27 11 803 2151 |If it doesn't work, force it! |
|Fax: +27 11 803 2189 |If it breaks, it needed replacing anyway!|
|Cell: +27 83 250 2325 |Well, that's how I code anyway! |
+------------------------+-----------------------------------------+