|
Posted by Kimmo Laine on 10/16/33 11:52
"ImOk" <jon.macaroni@gmail.com> wrote in message
news:1152463253.354344.105660@h48g2000cwc.googlegroups.com...
>I just have a question about trapping and retrying errors especially
> file locking or database locks or duplicate key errors.
>
> Is there a way after you trap an error to retry the same line that
> cause the error?
>
> In many other languages you have the option of rertying certain errors.
> In effect, its like a return to the exact same line. You can then retry
> certain # of times and then produce an error if it keeps failing.
I've done something like that, altough there is no direct language support
for that, you just have to make one. Anyway, I've got a database interface
class which I use for all queries, it has a built-in error reporting
mechanism which sends errors to my email address. Now, when the error
message contains the word "deadlock" I try to rerun the query, keeping track
how many times rerun has been attempted. Before another rerun, there's a
random length sleep period 0.5 ... 1.0 seconds, and then it's retried. If
after ten reruns it fails, I get the error report, but on most cases it runs
succesfully after 3 or 4. It's really handy. We always get those pesky
deadlocks once a day when a major task is performed during which the server
hits a performance peak, but thanks to the deadlock solver, the queries
eventually are ran even though it takes a little longer then.
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|