Errors within Transactions
A lock/reread, unlock block, and a begin_transaction, end_transaction block both define a scope. One consequence of this is that they must match—for each begin_transaction there must be an end_transaction—otherwise, you will receive an error at compile time.
Another consequence is that you should not exit the scope by calling (or returning from) procedures or functions. The only recommended way to exit a transaction is through the terminating statement (unlock, or end_transaction) or through an abort_transaction command.
Error Handling within Transaction Blocks
Here is a look at error handling within these blocks:
Lock/Reread
- (Non-transaction) error occurs:
- Report Error
-
Continue
-
Transaction error occurs:
- Check
transaction_retrysetting - Send
verify_retry(to the object containing the lock/reread)- If it is
0: retry (jump to lock/reread) - If it is non-zero: abort (jump to unlock)
- If it is
Unlock
- (Non-transaction) error occurs:
- Jump to
end_transaction -
Abort transaction, backing out to the state at the beginning of the transaction
-
Transaction error occurs:
- Check
transaction_retrysetting - Send
verify_retry(to the object containing thebegin_transaction)- If it is
0: retry (jump tobegin_transaction) - If it is non-zero: abort (jump to
end_transaction)
- If it is
Begin_transaction
End_transaction
Examples of transaction errors are deadlock, can't lock, or lock timeout. These are errors which the driver "thinks" have a reasonable chance of working, if tried again. This set is also user-definable; that is, you can add specific errors to the set of Transaction Errors.