Skip to content

RUBY-2806 Rate limit push monitor handshake sends #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2021
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
3 changes: 3 additions & 0 deletions lib/mongo/server/push_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def do_work
log_prefix: options[:log_prefix],
bg_error_backtrace: options[:bg_error_backtrace],
)

# Avoid tight looping in push monitor - see RUBY-2806.
sleep(0.5)
end

def check
Expand Down
19 changes: 19 additions & 0 deletions spec/mongo/server/push_monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@
push_monitor.do_work
end.should_not raise_error
end

it 'throttles checks' do
push_monitor

start = Mongo::Utils.monotonic_time

expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
lambda do
push_monitor.do_work
end.should_not raise_error

expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
lambda do
push_monitor.do_work
end.should_not raise_error

elapsed = Mongo::Utils.monotonic_time - start
elapsed.should > 0.5
end
end
end

Expand Down