Friday, January 9, 2009

acts_as_solr, solr_destory doesn't work as a callback

So we had a bug where acts_as_solr will screw up our data integrity when the server is down. The solr_destoy method will not catch the exception it throws when its down, so it doesn't work properly as a call back. I've decided to monkey patch it like so:

module ActsAsSolr::InstanceMethods
def solr_destroy_with_error_handling
begin
solr_destroy_without_error_handling
rescue => e
logger.error "error deleting from solr: #{e}\n#{e.backtrace.join("\n")}"
end
true
end

alias_method_chain :solr_destroy, :error_handling
end


which seems to work...

0 comments: