For example, the first set shows a transaction nested within another; the second set shows two separate transactions. Invalid sequence: Start trans1 Start trans2 Commit trans2 Commit trans1 Valid sequence: Start trans1 Commit trans1 Start trans2 Commit trans2 3DSpace does not allow nested transactions. However, savepoints can be used to divide large transactions into smaller parts. If the start() method of the context class is called a second time before the commit or abort methods are called for the first transaction, the system throws a MatrixException. Use the isTransactionActive() method to determine if a transaction is still alive before starting a transaction. If the result is false, it is safe to begin a transaction; if true, the current transaction must be aborted or committed before starting a new one. In addition, all exceptions within a transaction must be handled, else the transaction could get stranded. If the transaction is stranded, it cannot be recovered. Using a transaction timeout (to abort/commit the transaction once the threshold has been exceeded) can help to solve the problem of stranded transactions. |