I'd change the exception handling to only retry on certain errors:
- 1204, 1205 deadlocks
- -2 timeout
- -1 connection broken
These are the basic "retryable" errors
catch (SqlException ex)
{
if !(ex.Number == 1205 || ex.Number == 1204 || ... )
{
throw
}
retryCount++;
if (retryCount > MAX_RETRY) throw;
}
Edit, I clean forgot about waits so you don't hammer the SQL box:
- Add a 500 ms wait on deadlock
- Add a 5 sec delay on timeout
Edit 2:
I'm a Developer DBA, don't do much C#.
My answer was to correct exception processing for the calls...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…