pDeadlockHandler
pDeadlockHandler
Handle deadlock situations after database operations.
Syntax
pDeadLockHandler ( inout vlStatus,
inout vlRetryCount )
Parameters
vlStatus | A return value of either “ERROR” or blank. |
vlRetryCount | The current retry count on entry; can be updated by pDeadLockHandler |
Comments
The pDeadLockHandler provides a specific method of dealing with deadlock conditions during database operations. It would normally be called within an ON DEADLOCK construct. It enables transactions to be retried a specified number of times before an error message is produced.
The variable vMaxRetries (defined in $DeployServices) is assumed to contain the maximum number of times the applications wishes to retry a transaction that has deadlocked. It must be set by the application. For each transaction, the application should maintain a local variable that holds the current retry count, initially zero. When a deadlock is detected during a database operation such as ADD or CHANGE, pDeadLockHandler can be called. If the current retry count is less than the maximum permitted, the retry count is incremented and vlStatus is set to blank. The application then retries the application. If the retry count reaches or exceeds vMaxRetries, the user is asked if they wish to retry the transaction anyway. If they agree, vlStatus is set to blank. Otherwise, vlStatus is set to “ERROR”. The application should check for this return value and abandon the transaction.