lib/mongo/server/monitor.rb in mongo-2.18.3 vs lib/mongo/server/monitor.rb in mongo-2.19.0

- old
+ new

@@ -1,7 +1,7 @@ # frozen_string_literal: true -# encoding: utf-8 +# rubocop:todo all # Copyright (C) 2014-2020 MongoDB Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -221,25 +221,29 @@ # But it is also possible to invoke scan! directly on a monitor. # Allow only one scan to be performed at a time. @mutex.synchronize do throttle_scan_frequency! - result = do_scan - - run_sdam_flow(result) + begin + result = do_scan + rescue => e + run_sdam_flow({}, scan_error: e) + else + run_sdam_flow(result) + end end end - def run_sdam_flow(result, awaited: false) + def run_sdam_flow(result, awaited: false, scan_error: nil) @sdam_mutex.synchronize do old_description = server.description new_description = Description.new(server.address, result, average_round_trip_time: server.round_trip_time_averager.average_round_trip_time ) - server.cluster.run_sdam_flow(server.description, new_description, awaited: awaited) + server.cluster.run_sdam_flow(server.description, new_description, awaited: awaited, scan_error: scan_error) server.description.tap do |new_description| unless awaited if new_description.unknown? && !old_description.unknown? @next_earliest_scan = @next_wanted_scan = Time.now @@ -288,10 +292,10 @@ Utils.warn_bg_exception(msg, exc, logger: options[:logger], log_prefix: options[:log_prefix], bg_error_backtrace: options[:bg_error_backtrace], ) - {} + raise exc end end def check if @connection && @connection.pid != Process.pid