Class Recoverer

java.lang.Object
bitronix.tm.recovery.Recoverer
All Implemented Interfaces:
RecovererMBean, Service, Runnable

public class Recoverer extends Object implements Runnable, Service, RecovererMBean
Recovery process implementation. Here is Mike Spille's description of XA recovery:

Straight Line Recovery:

  • 1. Find transactions that the TM considers dangling and unresolved
  • 2. Find and reconstitute any XAResources which were being used when chunk blowing occured.
  • 3. Call the recover() method on each of these XAResources.
  • 4. Throw out any Xid's in the XAResource' recover lists which are not owned by this TM.
  • 5. Correlate Xid's that the TM knows about with remaining Xid's that the XAResources reported.
  • 6. For XAResource Xid's that match the global transaction ID which the TM found dangling with a "Committing..." record, call commit() on those XAResources for those Xids.
  • 7. For XAResource Xid's that do not match any dangling "Committing..." records, call rollback() on those XAResources for those Xids.
Exceptional conditions:
  • 1. For any rollback() calls from step 6 which reported a Heuristic Commit, you are in danger or doubt, so run in circles, scream and shout.
  • 2. For any commit() calls from step 7 which reported a Heuristic Rollback, you are in danger or doubt, so run in circles, scream and shout.
  • 3. For any resource you can't reconstitute in in step #2, or who fails on recover in step #3, or who reports anything like an XAER_RMFAILURE in step 6 or step 7, keep trying to contact them in some implementation defined manner.
  • 4. For any heuristic outcome you see reported from an XAResource, call forget() for that XAResource/Xid pair so that the resource can stop holding onto a reference to that transaction

To achieve this, Recoverer must have access to all previously used resources, even if the journal contains no trace of some of them. There are two ways of achieving this: either you use the ResourceLoader to configure all your resources and everything will be working automatically or by making sure resources are re-created and re-registered.

Those are the three steps of the Bitronix implementation:

  • call recover() on all known resources (Mike's steps 1 to 5)
  • commit dangling COMMITTING transactions (Mike's step 6)
  • rollback any remaining recovered transaction (Mike's step 7)

Author:
lorban
  • Constructor Details

    • Recoverer

      public Recoverer()
  • Method Details

    • shutdown

      public void shutdown()
      Description copied from interface: Service
      Shutdown the service and free all held resources.
      Specified by:
      shutdown in interface Service
    • run

      public void run()
      Run the recovery process. This method is automatically called by the transaction manager, you should never call it manually.
      Specified by:
      run in interface RecovererMBean
      Specified by:
      run in interface Runnable
    • getCompletionException

      public Exception getCompletionException()
      Get the exception reported when recovery failed.
      Specified by:
      getCompletionException in interface RecovererMBean
      Returns:
      the exception that made recovery fail or null if last recovery execution was successful.
    • getCommittedCount

      public int getCommittedCount()
      Get the amount of transactions committed during the last recovery run.
      Specified by:
      getCommittedCount in interface RecovererMBean
      Returns:
      the amount of committed transactions.
    • getRolledbackCount

      public int getRolledbackCount()
      Get the amount of transactions rolled back during the last recovery run.
      Specified by:
      getRolledbackCount in interface RecovererMBean
      Returns:
      the amount of rolled back transactions.
    • getExecutionsCount

      public int getExecutionsCount()
      Get how many times the recoverer has run since the transaction manager started.
      Specified by:
      getExecutionsCount in interface RecovererMBean
      Returns:
      how many times the recoverer has run since the transaction manager started.
    • isRunning

      public boolean isRunning()
      Check if the recoverer currently is running.
      Specified by:
      isRunning in interface RecovererMBean
      Returns:
      true if the recoverer currently is running, false otherwise.