Error handler testing for Microsoft errors

  • All my textbooks start at error 50000, so I'll try here...

    I need to develop code for a TRY...CATCH block in SQL Server 2008 R2 for the following error, that occurs when I get a timeout from a linked server that connects to a server in another country:

    OLE DB provider "ORAOLEDB.Oracle" for linked server "MyRemoteServer" returned message "ORA-12170: TNS:Connect timeout occurred".

    Msg 7303, Level 16, State 1, Line 77

    Cannot initialize the data source object of OLE DB provider "ORAOLEDB.Oracle" for linked server "MyRemoteServer".

    Most times, it doesn't time out, but occasionally gives me a 7303 error. I can't control when timeouts happen and when they don't. I can't use RAISERROR on error 7303, as it only works on custom errors >= 50000.

    My question is, how do I simulate a timeout so that I can verify my error handling code? I need a procedure that waits 10 seconds and tries again 3 times, but how do I generate the error?

    Thanks!

  • I had to do a lot of testing of data comms software many years ago, and we always arranged to have switchable relay somewhere in the link to test timeouts and/or a noise injector (which does just as well on protocols not using seriously redundant encoding, which is pretty well anything but distant space probe communication and some defence-related stuff, and is actually better if you want to test error recovery at lower levels) . Then you get a timeout by cutting the connection or injecting heavy noise for long enough. This is probably a better method than simulation, because you are generating real timeouts.

    I imagine that the relevant hardware is still available, although it may be a lot more expensive for fibre connections that for metal ones.

    Tom

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply