Skip to content

Commit 5cc14a1

Browse files
Implement reaping for lb
1 parent 2526fb6 commit 5cc14a1

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

Diff for: gemfiles/standard.rb

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def standard_dependencies
6565
gem 'tilt'
6666
# solargraph depends on rbs, which won't build on jruby for some reason
6767
gem 'solargraph', platforms: :mri
68+
gem 'ruby-lsp', platforms: :mri
6869
end
6970

7071
gem 'libmongocrypt-helper', '~> 1.8.0' if ENV['FLE'] == 'helper'

Diff for: lib/mongo/cluster/reapers/cursor_reaper.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ def kill_cursors
194194
server_api: server.options[:server_api],
195195
connection_global_id: kill_spec.connection_global_id,
196196
}
197-
op.execute(server, context: Operation::Context.new(options: options))
197+
if connection = kill_spec.connection
198+
op.execute_with_connection(connection, context: Operation::Context.new(options: options))
199+
connection.connection_pool.check_in(connection)
200+
else
201+
op.execute(server, context: Operation::Context.new(options: options))
202+
end
198203

199204
if session = kill_spec.session
200205
if session.implicit?

Diff for: lib/mongo/cursor.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ def initialize(view, result, server, options = {})
100100
check_in_connection
101101
else
102102
register
103-
ObjectSpace.define_finalizer(self, self.class.finalize(kill_spec(@connection_global_id),
104-
cluster))
103+
ObjectSpace.define_finalizer(
104+
self,
105+
self.class.finalize(kill_spec(@connection_global_id), cluster)
106+
)
105107
end
106108
end
107109

@@ -406,6 +408,7 @@ def kill_spec(connection_global_id)
406408
connection_global_id: connection_global_id,
407409
server_address: server.address,
408410
session: @session,
411+
connection: @connection
409412
)
410413
end
411414

Diff for: lib/mongo/cursor/kill_spec.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@ def initialize(
3131
db_name:,
3232
connection_global_id:,
3333
server_address:,
34-
session:
34+
session:,
35+
connection: nil
3536
)
3637
@cursor_id = cursor_id
3738
@coll_name = coll_name
3839
@db_name = db_name
3940
@connection_global_id = connection_global_id
4041
@server_address = server_address
4142
@session = session
43+
@connection = connection
4244
end
4345

4446
attr_reader :cursor_id,
4547
:coll_name,
4648
:db_name,
4749
:connection_global_id,
4850
:server_address,
49-
:session
51+
:session,
52+
:connection
5053

5154
def ==(other)
5255
cursor_id == other.cursor_id &&

Diff for: spec/integration/cursor_reaping_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
let(:subscriber) { Mrss::EventSubscriber.new }
2525

2626
let(:client) do
27-
authorized_client.tap do |client|
27+
authorized_client.with(max_pool_size: 10).tap do |client|
2828
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
2929
end
3030
end

0 commit comments

Comments
 (0)