C
Charlie
Hi,
I have written an application that recently, under heavy load,
encountered the deadlock. After considering the time issue, I decided
to live with them. However, I have trouble reproducing them in order
to trap and handle them properly. Could someone please tell me what's
the Number it returned in the SQLException object so that my following
exception handling code would work?
Q1: Is the Number = 1025 or 10255 for deadlock?
Q2: Is 1 second a good interval for the victim to wait before retry?
While completed = false
Try
commit transaction
success = true
Catch SQLDeadlock As SQLException
If ErrorCount < RetryCount Then
For ErrorIndex = 0 To SQLDeadlock.Errors.Count
// catch deadlock, no need to roll back for it's handled by
DB
If SQLDeadLock.Errors(ErrorIndex).Number = 10255 Then
System.Threading.Thread.Sleep(1000)
LogErrorEvent(...)
Else
// catch other sql exceptions and roll back transaction
roll back transaction
LogErrorEvent(...)
End If
Next
Else
LogErrorEvent(...)
Exit While
End If
Catch ex As Exception
MsgBox(ex.tostring)
Finally
If success Then
complete = true
dispose transaction
else
ErrorCount += 1
end if
End Try
End While
Thank you for your help.
Charlie Chang
(e-mail address removed)
I have written an application that recently, under heavy load,
encountered the deadlock. After considering the time issue, I decided
to live with them. However, I have trouble reproducing them in order
to trap and handle them properly. Could someone please tell me what's
the Number it returned in the SQLException object so that my following
exception handling code would work?
Q1: Is the Number = 1025 or 10255 for deadlock?
Q2: Is 1 second a good interval for the victim to wait before retry?
While completed = false
Try
commit transaction
success = true
Catch SQLDeadlock As SQLException
If ErrorCount < RetryCount Then
For ErrorIndex = 0 To SQLDeadlock.Errors.Count
// catch deadlock, no need to roll back for it's handled by
DB
If SQLDeadLock.Errors(ErrorIndex).Number = 10255 Then
System.Threading.Thread.Sleep(1000)
LogErrorEvent(...)
Else
// catch other sql exceptions and roll back transaction
roll back transaction
LogErrorEvent(...)
End If
Next
Else
LogErrorEvent(...)
Exit While
End If
Catch ex As Exception
MsgBox(ex.tostring)
Finally
If success Then
complete = true
dispose transaction
else
ErrorCount += 1
end if
End Try
End While
Thank you for your help.
Charlie Chang
(e-mail address removed)