RollBack Transaction Command

The rollback-transaction command rolls back the specific transaction (identified by transaction-id).

This command may be used when any of the following situations (which i can think of) occur
1) the transaction is hanging on the server waiting for a resource
2) for some reasons transaction is taking long time to execute.

Following are the steps which demonstrates how to use the rollback-transaction command


1) To roll back the transaction you need to enable the monitoring for transaction service. This is done by executing the following command
asadmin set server.monitoring-service.module-monitoring-levels.transaction-service=HIGH

2) Deployed an application which does an active transaction for a minute like adding values to a table in a database.

3) When you want to rollback a transaction, freeze the transaction service to lock it by executing the following command
asadmin freeze-transaction-service

4) Get the list of active transaction by executing the following command
asadmin get -m "server.transaction-service.\*"
server.transaction-service.activecount-count = 1
server.transaction-service.activecount-description = Provides the number of transactions that are currently active.
server.transaction-service.activecount-lastsampletime = 1254431281781
server.transaction-service.activecount-name = ActiveCount
server.transaction-service.activecount-starttime = 1254430982059
server.transaction-service.activecount-unit = count
server.transaction-service.activeids-current =
Transaction Id                          Status                   ElapsedTime(ms)          ComponentName                                   ResourceNames

0000000000000001_00                     Active                   68566                    org.nachi.transactiontest.ejb.SimpleSessionBean jdbc/__default,
server.transaction-service.activeids-description = Provides the IDs of the transactions that are currently active a.k.a. in-flight transactions. Every such transaction can be rolled back after freezing the transaction service.
server.transaction-service.activeids-lastsampletime = 1254431350346
server.transaction-service.activeids-name = ActiveIds
server.transaction-service.activeids-starttime = 1254430982061
server.transaction-service.activeids-unit = List
server.transaction-service.committedcount-count = 0
server.transaction-service.committedcount-description = Provides the number of transactions that have been committed.
server.transaction-service.committedcount-lastsampletime = -1
server.transaction-service.committedcount-name = CommittedCount
server.transaction-service.committedcount-starttime = 1254430982059
server.transaction-service.committedcount-unit = count
server.transaction-service.dotted-name = server.transaction-service
server.transaction-service.rolledbackcount-count = 0
server.transaction-service.rolledbackcount-description = Provides the number of transactions that have been rolled back.
server.transaction-service.rolledbackcount-lastsampletime = -1
server.transaction-service.rolledbackcount-name = RolledbackCount
server.transaction-service.rolledbackcount-starttime = 1254430982059
server.transaction-service.rolledbackcount-unit = count
server.transaction-service.state-current = True
server.transaction-service.state-description = Indicates if the transaction service has been frozen
server.transaction-service.state-lastsampletime = 1254431350346
server.transaction-service.state-name = State
server.transaction-service.state-starttime = 1254430982063
server.transaction-service.state-unit = String

5) From the output you can observe that there is one active transaction. Say you want to rollback the active transaction. Execute the following command with the specific transaction id
asadmin rollback-transaction 0000000000000001_00


6)  Check the status of the transactions by executing the following command
asadmin get -m "server.transaction-service.\*"
From the output fragment you can observe that transaction is marked as rollback
Transaction Id                          Status                   ElapsedTime(ms)          ComponentName                                   ResourceNames

0000000000000001_00                     Rollback                   68566                    org.nachi.transactiontest.ejb.SimpleSessionBean jdbc/__default

7) Unfreeze transaction service and check if the active transaction is cancelled (No values should have been added to the table).

In the next blog i will be talking about recover transaction cli command.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Nachiappan Veerappan Nachiappan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today