Sometimes it happens that a DML statement on a large table causes a ROLLBACK to be executed which runs for a very long time. Often you have to make the decision to wait until the ROLLBACK is finished or to abort the ROLLBACK.
Canceling a rollback has the advantage that no further resources are wasted and is especially useful if the ROLLBACK does not allow the system to run in parallel (high skew) and therefore the entire workload is affected.
Nevertheless, you have to think carefully about what you are doing, because the affected table will end up in an inconsistent state and practically unusable. Therefore, the termination of a ROLLBACK is only desirable in the following cases:
- The ROLLBACK is expected to take longer than restoring the table
- It is a table that is only used temporarily and is therefore insignificant and can be rebuilt at any time
A practical example of Teradata Cancel Rollback
Suppose the SQL statement below is executed on the DWHPRO.NUSI_TEST table, which contains 100 million rows:
UPDATE DWHPRO.NUSI_TEST SET COL2 = 1 WHERE COL2 <= 80
Finally, after waiting another hour, it is still not finished and in Viewpoint, we see the reason: The ROLLBACK is skewed and is done on a single AMP!
The table is a temporary table and therefore not important for us. But the parallelism of the Teradata system is destroyed by the ROLLBACK on an AMP. We, therefore, decide to cancel the ROLLBACK.
Teradata Cancel Rollback - Checklist
Here are the individual steps you need to take:
Teradata Cancel Rollback in detail
- On the Linux console we execute the following command to see if a ROLLBACK is in progress at all:
awtmon 1 100
The first parameter is the interval (in seconds) in which the AMPs are tested, the second parameter determines how often the AMPs are tested in a loop (100 times).
- Starting the Database Window
To do this, execute the following command in the Linux shell:
- Starting the Recovery Managers (rcvmanager)
Click on the icon "rcvmanager" to open the window where you can cancel the ROLLBACK (in the graphic above it is the icon on the left side). The following window opens:
- List the tables in ROLLBACK status
Type list rollback tables; (where it says "Enter a command"). Don't forget the semicolon.
You get a list with TableID, database and table name of the tables which have the status "ROLLBACK". Ours has the TableId "0000:0FF8".
You can also see how many rows are still in the transient journal (TJ rows left) and how many have already been rolled back (TJ rows done) as well as an estimate of the expected runtime (to be used with caution, especially with strong skew)
- Termination of the ROLLBACK
To cancel the ROLLBACK you have to execute the following command:
cancel rollback on table 0000:0FF8
Confirm with 'y' that you really want to cancel the rollback, and you will get the message "Rollback on "DATABASE"."TABLE" is canceled.
You will also be reminded that the table is now invalidated and only limits its use to a few cases.
What activities can be performed on the table after canceling the ROLLBACK?
- DELETE DWHPRO.NUSI_TEST
- The rebuilding of the table headers
- DROP TABLE DWHPRO.NUSI_TEST
- Restore the table from an archive
- Dump the table to an archive
If you try to query the table you will get this error message:
SELECT * FROM DWHPRO.NUSI_TEST; SELECT Failed:  Invalid operation on table DWHPRO.NUSI_TEST.
After deleting all rows it can be used as usual again:
DELETE FROM DWHPRO.NUSI_TEST; SELECT * FROM DWHPRO.NUSI_TEST; SELECT completed. 0 Rows returned. Elapsed time = 00:00:00
Teradata CANCEL ROLLBACK is a way of ending a ROLLBACK in an emergency.
Under no circumstances should it be used lightly, as it renders the affected table unusable. In any case, you should check in the recovery manager how many rows are left in the Transient Journal (TJ rows left) and how quickly the number of rows decreases before you take this drastic measure.