on 11-03-2015 4:48 AM
I have 5500 items and 450 BOM's. I want to update the price of all the items and then I will update the price of BOM. When I run the add-on, sometimes SAP gets hanged and sometimes I receive the following error -
Could not commit transaction: Deadlock(-2038) detected during transaction
Hi Dilip,
Below a quote from the SDK Help file
SAP Business One SDK 9.0 |
In a landscape with more than one client, it is possible that database deadlocks will occur. In most cases, an add-on can handle potential deadlocks simply by retrying the operation.
When handling deadlocks, the following rules apply:
The following is an example of handling potential deadlocks:
const long DEADLOCK_ERR_CODE = -2038;
long DeadlockTryTime = 100;
long i =0;
bool retCode = false;
for (i=0; i<DeadlockTryTime; i++)
{
try
{
retCode = DoOperations(); //start end transaction are contained within the function.
if (returnCode == success)
{
break;
}
else
{
// basic error handling
}
}
catch (System.Runtime.InteropServices.COMException ex)
{
if (ex.ErrorCode == DEADLOCK_ERR_CODE)
{
continue;
}
else
{
// error handling for non-deadlock ComException exceptions
}
}
}
if (i == DeadlockTryTime)
{
// Handle that deadlock retry failed
}
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
-2038 is a common time-out / deadlock error. This can sometimes happen, especially when you perform a lot of transactions.
In your addon you should build in an error checking routine that detects the -2038 error, and that simply retries the transaction after a couple of milliseconds.
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
11 | |
11 | |
6 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.