mongo 2.9.0 → 2.9.1.rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mongo/client.rb +10 -6
- data/lib/mongo/server.rb +16 -0
- data/lib/mongo/version.rb +1 -1
- data/spec/integration/sdam_error_handling_spec.rb +95 -53
- data/spec/integration/step_down_spec.rb +6 -3
- data/spec/mongo/client_construction_spec.rb +46 -0
- data/spec/mongo/server/connection_spec.rb +10 -5
- data/spec/mongo/server/monitor/connection_spec.rb +3 -1
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e682274ba299fe9da1e373641236dd929ad81784a68a8f873a0461343835980
|
4
|
+
data.tar.gz: 9b5aba8b96ee2a5d7c1cf3f0df73ca93de5ce0e921da3df2e45fb165d6a28bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7afd6d03c3c5c5691c5b34bab63a0deddb95d779bbaf1d80e011ade79856e65cc3677d77388a89cedfa9d56f70c528d88210e76aeff3b8d65b30026bee8cc5d6
|
7
|
+
data.tar.gz: 28f0da296a9852c66a14cc19c1578168ccd549f0f1e9a0c9a143fb109d7ae57ab74c84a90569415219c039840ca59145420cc8e10f0a04413b10638d00ad3217
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mongo/client.rb
CHANGED
@@ -346,14 +346,10 @@ module Mongo
|
|
346
346
|
else
|
347
347
|
options = {}
|
348
348
|
end
|
349
|
-
|
350
|
-
options[:retry_reads] = true
|
351
|
-
end
|
352
|
-
unless options[:retry_writes] == false
|
353
|
-
options[:retry_writes] = true
|
354
|
-
end
|
349
|
+
|
355
350
|
Lint.validate_underscore_read_preference(options[:read])
|
356
351
|
Lint.validate_read_concern_option(options[:read_concern])
|
352
|
+
|
357
353
|
if addresses_or_uri.is_a?(::String)
|
358
354
|
uri = URI.get(addresses_or_uri, options)
|
359
355
|
addresses = uri.servers
|
@@ -361,6 +357,14 @@ module Mongo
|
|
361
357
|
else
|
362
358
|
addresses = addresses_or_uri
|
363
359
|
end
|
360
|
+
|
361
|
+
unless options[:retry_reads] == false
|
362
|
+
options[:retry_reads] = true
|
363
|
+
end
|
364
|
+
unless options[:retry_writes] == false
|
365
|
+
options[:retry_writes] = true
|
366
|
+
end
|
367
|
+
|
364
368
|
# Special handling for sdam_proc as it is only used during client
|
365
369
|
# construction
|
366
370
|
sdam_proc = options.delete(:sdam_proc)
|
data/lib/mongo/server.rb
CHANGED
@@ -417,7 +417,23 @@ module Mongo
|
|
417
417
|
|
418
418
|
# @api private
|
419
419
|
def update_description(description)
|
420
|
+
prev_description = monitor.instance_variable_get('@description')
|
420
421
|
monitor.instance_variable_set('@description', description)
|
422
|
+
if description.unknown? && !prev_description.unknown?
|
423
|
+
# This clears redundantly sometimes and also clears the pool on
|
424
|
+
# 4.2+ servers after not master errors which should not be done.
|
425
|
+
# Driver version 2.11+ has the correct implementation.
|
426
|
+
clear_connection_pool
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
# @api private
|
431
|
+
def clear_connection_pool
|
432
|
+
@pool_lock.synchronize do
|
433
|
+
if @pool
|
434
|
+
@pool.disconnect!
|
435
|
+
end
|
436
|
+
end
|
421
437
|
end
|
422
438
|
|
423
439
|
# @api private
|
data/lib/mongo/version.rb
CHANGED
@@ -5,8 +5,64 @@ describe 'SDAM error handling' do
|
|
5
5
|
ClientRegistry.instance.close_all_clients
|
6
6
|
end
|
7
7
|
|
8
|
+
# These tests operate on specific servers, and don't work in a multi
|
9
|
+
# shard cluster where multiple servers are equally eligible
|
10
|
+
require_topology :replica_set
|
11
|
+
|
12
|
+
let(:client) { authorized_client_without_any_retries }
|
13
|
+
|
14
|
+
let(:server) { client.cluster.next_primary }
|
15
|
+
|
16
|
+
shared_examples_for 'marks server unknown' do
|
17
|
+
it 'marks server unknown' do
|
18
|
+
expect(server).not_to be_unknown
|
19
|
+
operation
|
20
|
+
expect(server).to be_unknown
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shared_examples_for 'does not mark server unknown' do
|
25
|
+
it 'does not mark server unknown' do
|
26
|
+
expect(server).not_to be_unknown
|
27
|
+
operation
|
28
|
+
expect(server).not_to be_unknown
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
shared_examples_for 'requests server scan' do
|
33
|
+
it 'requests server scan' do
|
34
|
+
expect(server.monitor.scan_semaphore).to receive(:signal)
|
35
|
+
operation
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
shared_examples_for 'does not request server scan' do
|
40
|
+
it 'does not request server scan' do
|
41
|
+
expect(server.monitor.scan_semaphore).not_to receive(:signal)
|
42
|
+
operation
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
shared_examples_for 'clears connection pool' do
|
47
|
+
it 'clears connection pool' do
|
48
|
+
generation = server.pool.generation
|
49
|
+
operation
|
50
|
+
new_generation = server.pool.generation
|
51
|
+
# Temporary hack to allow repeated pool clears
|
52
|
+
expect(new_generation).to be >= generation + 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
shared_examples_for 'does not clear connection pool' do
|
57
|
+
it 'does not clear connection pool' do
|
58
|
+
generation = server.pool.generation
|
59
|
+
operation
|
60
|
+
new_generation = server.pool.generation
|
61
|
+
expect(new_generation).to eq(generation)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
8
65
|
describe 'when there is an error during an operation' do
|
9
|
-
let(:client) { authorized_client_without_any_retries }
|
10
66
|
|
11
67
|
before do
|
12
68
|
wait_for_all_servers(client.cluster)
|
@@ -15,12 +71,10 @@ describe 'SDAM error handling' do
|
|
15
71
|
# have different behavior from non-handshake errors
|
16
72
|
client.database.command(ping: 1)
|
17
73
|
client.cluster.servers_list.each do |server|
|
18
|
-
server.monitor.stop!
|
74
|
+
server.monitor.stop!
|
19
75
|
end
|
20
76
|
end
|
21
77
|
|
22
|
-
let(:server) { client.cluster.next_primary }
|
23
|
-
|
24
78
|
let(:operation) do
|
25
79
|
expect_any_instance_of(Mongo::Server::Connection).to receive(:deliver).and_return(reply)
|
26
80
|
expect do
|
@@ -28,54 +82,6 @@ describe 'SDAM error handling' do
|
|
28
82
|
end.to raise_error(Mongo::Error::OperationFailure, exception_message)
|
29
83
|
end
|
30
84
|
|
31
|
-
shared_examples_for 'marks server unknown' do
|
32
|
-
it 'marks server unknown' do
|
33
|
-
expect(server).not_to be_unknown
|
34
|
-
operation
|
35
|
-
expect(server).to be_unknown
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
shared_examples_for 'does not mark server unknown' do
|
40
|
-
it 'does not mark server unknown' do
|
41
|
-
expect(server).not_to be_unknown
|
42
|
-
operation
|
43
|
-
expect(server).not_to be_unknown
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
shared_examples_for 'requests server scan' do
|
48
|
-
it 'requests server scan' do
|
49
|
-
expect(server.monitor.scan_semaphore).to receive(:signal)
|
50
|
-
operation
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
shared_examples_for 'does not request server scan' do
|
55
|
-
it 'does not request server scan' do
|
56
|
-
expect(server.monitor.scan_semaphore).not_to receive(:signal)
|
57
|
-
operation
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
shared_examples_for 'clears connection pool' do
|
62
|
-
it 'clears connection pool' do
|
63
|
-
generation = server.pool.generation
|
64
|
-
operation
|
65
|
-
new_generation = server.pool.generation
|
66
|
-
expect(new_generation).to eq(generation + 1)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
shared_examples_for 'does not clear connection pool' do
|
71
|
-
it 'does not clear connection pool' do
|
72
|
-
generation = server.pool.generation
|
73
|
-
operation
|
74
|
-
new_generation = server.pool.generation
|
75
|
-
expect(new_generation).to eq(generation)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
85
|
shared_examples_for 'not master or node recovering' do
|
80
86
|
it_behaves_like 'marks server unknown'
|
81
87
|
it_behaves_like 'requests server scan'
|
@@ -83,7 +89,8 @@ describe 'SDAM error handling' do
|
|
83
89
|
context 'server 4.2 or higher' do
|
84
90
|
min_server_fcv '4.2'
|
85
91
|
|
86
|
-
|
92
|
+
# Due to RUBY-1894 backport, the pool is cleared here
|
93
|
+
it_behaves_like 'clears connection pool'
|
87
94
|
end
|
88
95
|
|
89
96
|
context 'server 4.0 or lower' do
|
@@ -165,4 +172,39 @@ describe 'SDAM error handling' do
|
|
165
172
|
end
|
166
173
|
end
|
167
174
|
end
|
175
|
+
|
176
|
+
# These tests fail intermittently in Evergreen
|
177
|
+
describe 'when there is an error on monitoring connection', retry: 3 do
|
178
|
+
let(:client) do
|
179
|
+
authorized_client_without_any_retries.with(
|
180
|
+
connect_timeout: 1, socket_timeout: 1)
|
181
|
+
end
|
182
|
+
|
183
|
+
let(:operation) do
|
184
|
+
expect(server.monitor.connection).not_to be nil
|
185
|
+
expect(server.monitor.connection).to receive(:ismaster).at_least(:once).and_raise(exception)
|
186
|
+
server.monitor.scan_semaphore.broadcast
|
187
|
+
6.times do
|
188
|
+
sleep 0.5
|
189
|
+
if server.unknown?
|
190
|
+
break
|
191
|
+
end
|
192
|
+
end
|
193
|
+
expect(server).to be_unknown
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'non-timeout network error' do
|
197
|
+
let(:exception) { Mongo::Error::SocketError }
|
198
|
+
|
199
|
+
it_behaves_like 'marks server unknown'
|
200
|
+
it_behaves_like 'clears connection pool'
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'network timeout' do
|
204
|
+
let(:exception) { Mongo::Error::SocketTimeoutError }
|
205
|
+
|
206
|
+
it_behaves_like 'marks server unknown'
|
207
|
+
it_behaves_like 'clears connection pool'
|
208
|
+
end
|
209
|
+
end
|
168
210
|
end
|
@@ -154,7 +154,8 @@ describe 'Step down behavior' do
|
|
154
154
|
collection.insert_one(test: 1)
|
155
155
|
end.to raise_error(Mongo::Error::OperationFailure, /10107/)
|
156
156
|
|
157
|
-
|
157
|
+
# Temporarily add 1 due to RUBY-1894 backport
|
158
|
+
expect(event_subscriber.select_published_events(Mongo::Monitoring::Event::Cmap::PoolCleared).count).to eq(0+1)
|
158
159
|
end
|
159
160
|
end
|
160
161
|
|
@@ -173,7 +174,8 @@ describe 'Step down behavior' do
|
|
173
174
|
collection.insert_one(test: 1)
|
174
175
|
end.to raise_error(Mongo::Error::OperationFailure, /10107/)
|
175
176
|
|
176
|
-
|
177
|
+
# Temporarily add 1 due to RUBY-1894 backport
|
178
|
+
expect(event_subscriber.select_published_events(Mongo::Monitoring::Event::Cmap::PoolCleared).count).to eq(1+1)
|
177
179
|
end
|
178
180
|
end
|
179
181
|
|
@@ -190,7 +192,8 @@ describe 'Step down behavior' do
|
|
190
192
|
collection.insert_one(test: 1)
|
191
193
|
end.to raise_error(Mongo::Error::OperationFailure, /11600/)
|
192
194
|
|
193
|
-
|
195
|
+
# Temporarily add 1 due to RUBY-1894 backport
|
196
|
+
expect(event_subscriber.select_published_events(Mongo::Monitoring::Event::Cmap::PoolCleared).count).to eq(1+1)
|
194
197
|
end
|
195
198
|
end
|
196
199
|
end
|
@@ -742,6 +742,52 @@ describe Mongo::Client do
|
|
742
742
|
end
|
743
743
|
end
|
744
744
|
end
|
745
|
+
|
746
|
+
context 'when retryReads URI option is given' do
|
747
|
+
|
748
|
+
context 'it is false' do
|
749
|
+
let!(:uri) do
|
750
|
+
'mongodb://127.0.0.1:27017/testdb?retryReads=false'
|
751
|
+
end
|
752
|
+
|
753
|
+
it 'sets the option on the client' do
|
754
|
+
expect(client.options[:retry_reads]).to be false
|
755
|
+
end
|
756
|
+
end
|
757
|
+
|
758
|
+
context 'it is true' do
|
759
|
+
let!(:uri) do
|
760
|
+
'mongodb://127.0.0.1:27017/testdb?retryReads=true'
|
761
|
+
end
|
762
|
+
|
763
|
+
it 'sets the option on the client' do
|
764
|
+
expect(client.options[:retry_reads]).to be true
|
765
|
+
end
|
766
|
+
end
|
767
|
+
end
|
768
|
+
|
769
|
+
context 'when retryWrites URI option is given' do
|
770
|
+
|
771
|
+
context 'it is false' do
|
772
|
+
let!(:uri) do
|
773
|
+
'mongodb://127.0.0.1:27017/testdb?retryWrites=false'
|
774
|
+
end
|
775
|
+
|
776
|
+
it 'sets the option on the client' do
|
777
|
+
expect(client.options[:retry_writes]).to be false
|
778
|
+
end
|
779
|
+
end
|
780
|
+
|
781
|
+
context 'it is true' do
|
782
|
+
let!(:uri) do
|
783
|
+
'mongodb://127.0.0.1:27017/testdb?retryWrites=true'
|
784
|
+
end
|
785
|
+
|
786
|
+
it 'sets the option on the client' do
|
787
|
+
expect(client.options[:retry_writes]).to be true
|
788
|
+
end
|
789
|
+
end
|
790
|
+
end
|
745
791
|
end
|
746
792
|
|
747
793
|
context 'when options are provided not in the string' do
|
@@ -270,6 +270,7 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
+
=begin These assertions require a working cluster with working SDAM flow, which the tests do not configure
|
273
274
|
shared_examples_for 'does not disconnect connection pool' do
|
274
275
|
it 'does not disconnect non-monitoring sockets' do
|
275
276
|
allow(server).to receive(:pool).and_return(pool)
|
@@ -285,6 +286,7 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
285
286
|
error
|
286
287
|
end
|
287
288
|
end
|
289
|
+
=end
|
288
290
|
|
289
291
|
let(:auth_mechanism) do
|
290
292
|
if ClusterConfig.instance.server_version >= '3'
|
@@ -331,14 +333,14 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
331
333
|
expect(error).to be_a(Mongo::Auth::Unauthorized)
|
332
334
|
end
|
333
335
|
|
334
|
-
it_behaves_like 'disconnects connection pool'
|
336
|
+
#it_behaves_like 'disconnects connection pool'
|
335
337
|
it_behaves_like 'keeps server type and topology'
|
336
338
|
end
|
337
339
|
|
338
340
|
# need a separate context here, otherwise disconnect expectation
|
339
341
|
# is ignored due to allowing disconnects in the other context
|
340
342
|
context 'checking pool disconnection' do
|
341
|
-
it_behaves_like 'disconnects connection pool'
|
343
|
+
#it_behaves_like 'disconnects connection pool'
|
342
344
|
end
|
343
345
|
end
|
344
346
|
|
@@ -368,7 +370,7 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
368
370
|
expect(error).to be_a(Mongo::Error::SocketTimeoutError)
|
369
371
|
end
|
370
372
|
|
371
|
-
it_behaves_like 'does not disconnect connection pool'
|
373
|
+
#it_behaves_like 'does not disconnect connection pool'
|
372
374
|
it_behaves_like 'keeps server type and topology'
|
373
375
|
end
|
374
376
|
|
@@ -398,7 +400,7 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
398
400
|
expect(error).to be_a(Mongo::Error::SocketError)
|
399
401
|
end
|
400
402
|
|
401
|
-
it_behaves_like 'disconnects connection pool'
|
403
|
+
#it_behaves_like 'disconnects connection pool'
|
402
404
|
it_behaves_like 'marks server unknown'
|
403
405
|
end
|
404
406
|
|
@@ -706,7 +708,8 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
706
708
|
end
|
707
709
|
|
708
710
|
it 'disconnects connection pool' do
|
709
|
-
|
711
|
+
# Allow multiple calls due to RUBY-1894 backport
|
712
|
+
expect(server.pool).to receive(:disconnect!).at_least(:once)
|
710
713
|
result
|
711
714
|
end
|
712
715
|
|
@@ -739,10 +742,12 @@ describe Mongo::Server::Connection, retry: 3 do
|
|
739
742
|
expect(connection).to_not be_connected
|
740
743
|
end
|
741
744
|
|
745
|
+
=begin These assertions require a working cluster with working SDAM flow, which the tests do not configure
|
742
746
|
it 'does not disconnect connection pool' do
|
743
747
|
expect(server.pool).not_to receive(:disconnect!)
|
744
748
|
result
|
745
749
|
end
|
750
|
+
=end
|
746
751
|
|
747
752
|
it 'does not mark server unknown' do
|
748
753
|
expect(server).not_to be_unknown
|
@@ -11,7 +11,7 @@ describe Mongo::Server::Monitor::Connection do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:address) do
|
14
|
-
|
14
|
+
Mongo::Address.new(ClusterConfig.instance.primary_address, options)
|
15
15
|
end
|
16
16
|
|
17
17
|
declare_topology_double
|
@@ -31,6 +31,8 @@ describe Mongo::Server::Monitor::Connection do
|
|
31
31
|
Mongo::Event::Listeners.new, options)
|
32
32
|
end
|
33
33
|
|
34
|
+
let(:monitor) { server.monitor }
|
35
|
+
|
34
36
|
let(:connection) do
|
35
37
|
# NB this connection is set up in the background thread,
|
36
38
|
# when the :scan option to client is changed to default to false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.1.rc0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
|
32
32
|
Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2019-06
|
34
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bson
|
@@ -1088,11 +1088,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1088
1088
|
version: '0'
|
1089
1089
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1090
1090
|
requirements:
|
1091
|
-
- - "
|
1091
|
+
- - ">"
|
1092
1092
|
- !ruby/object:Gem::Version
|
1093
|
-
version:
|
1093
|
+
version: 1.3.1
|
1094
1094
|
requirements: []
|
1095
|
-
rubygems_version: 3.0.
|
1095
|
+
rubygems_version: 3.0.3
|
1096
1096
|
signing_key:
|
1097
1097
|
specification_version: 4
|
1098
1098
|
summary: Ruby driver for MongoDB
|
metadata.gz.sig
CHANGED
Binary file
|