diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-20 14:40:02 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-20 14:40:02 +0000 |
commit | 9e3d6daed829b458fb78f0f8f34d268163ebdc2a (patch) | |
tree | 06816d8bb769176fcc05e253fc7f99c788bc3dbe /lib | |
parent | 63d19509dd6858dca025b68e3557914fa5e4cc18 (diff) |
Explicitly handle BDB::Fatal errors by dumping database stats and restarting
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/dbhash.rb | 15 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 15 |
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/rbot/dbhash.rb b/lib/rbot/dbhash.rb index 3168f208..2170ea08 100644 --- a/lib/rbot/dbhash.rb +++ b/lib/rbot/dbhash.rb @@ -135,6 +135,21 @@ module Irc end end + def DBTree.stats() + begin + debug "General stats:" + debug @@env.stat + debug "Lock stats:" + debug @@env.lock_stat + debug "Log stats:" + debug @@env.log_stat + debug "Txn stats:" + debug @@env.txn_stat + rescue + debug "Couldn't dump stats" + end + end + def DBTree.cleanup_env() begin debug "DBTree: checking transactions ..." diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index d513cb71..8e6fabac 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -376,11 +376,19 @@ class IrcBot rescue SystemExit exit 0 rescue TimeoutError, SocketError => e - puts "#{e.class}: #{e}" + puts "network exception: #{e.class}: #{e}" + debug e.inspect debug e.backtrace.join("\n") + rescue BDB::Fatal => e + puts "fatal bdb error: #{e.class}: #{e}" + debug e.inspect + debug e.backtrace.join("\n") + DBTree.stats + restart("Oops, we seem to have registry problems ...") rescue Exception => e - puts "network exception: #{e.inspect}" - puts e.backtrace.join("\n") + puts "non-net exception: #{e.class}: #{e}" + debug e.inspect + debug e.backtrace.join("\n") @socket.shutdown # now we reconnect rescue => e puts "unexpected exception: connection closed: #{e.inspect}" @@ -545,6 +553,7 @@ class IrcBot shutdown(msg) sleep @config['server.reconnect_wait'] # now we re-exec + # Note, this fails on Windows exec($0, *@argv) end |