Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/mongo/collection/view/aggregation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Aggregation
# The reroute message.
#
# @since 2.1.0
# @deprecated
REROUTE = 'Rerouting the Aggregation operation to the primary server.'.freeze

# Set to true if disk usage is allowed during the aggregation.
Expand Down Expand Up @@ -120,8 +121,8 @@ def secondary_ok?

def send_initial_query(server, session)
unless valid_server?(server)
log_warn(REROUTE)
server = cluster.next_primary(false)
log_warn("Rerouting the Aggregation operation to the primary server - #{server.summary} is not suitable")
server = cluster.next_primary
end
validate_collation!(server)
initial_query_op(session).execute(server)
Expand Down
5 changes: 3 additions & 2 deletions lib/mongo/collection/view/map_reduce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MapReduce
# Reroute message.
#
# @since 2.1.0
# @deprecated
REROUTE = 'Rerouting the MapReduce operation to the primary server.'.freeze

# @return [ View ] view The collection view.
Expand Down Expand Up @@ -232,8 +233,8 @@ def secondary_ok?

def send_initial_query(server, session)
unless valid_server?(server)
log_warn(REROUTE)
server = cluster.next_primary(false)
log_warn("Rerouting the MapReduce operation to the primary server - #{server.summary} is not suitable")
server = cluster.next_primary
end
validate_collation!(server)
initial_query_op(session).execute(server)
Expand Down
8 changes: 8 additions & 0 deletions spec/mongo/collection/view/map_reduce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,14 @@
end

context 'when the server is a valid for writing' do
before do
# We are inspecting server state - kill monitor threads so that
# server state is not changed in background due to intermittent
# connectivity issues in Evergreen
authorized_collection.client.cluster.servers_list.map do |server|
server.monitor.stop!
end
end

it 'does not reroute the operation to a primary' do
expect(Mongo::Logger.logger).not_to receive(:warn?)
Expand Down
3 changes: 2 additions & 1 deletion spec/mongo/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@

context 'server is unknown' do
let(:server) do
described_class.new(address, cluster, monitoring, listeners, SpecConfig.instance.test_options)
described_class.new(address, cluster, monitoring, listeners,
SpecConfig.instance.test_options.merge(monitoring_io: false))
end

before do
Expand Down