From 9e3d6daed829b458fb78f0f8f34d268163ebdc2a Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 20 Jul 2006 14:40:02 +0000 Subject: [PATCH] Explicitly handle BDB::Fatal errors by dumping database stats and restarting --- lib/rbot/dbhash.rb | 15 +++++++++++++++ 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 -- 2.39.2