-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.2, 2.13.0
-
Component/s: None
-
None
-
(copied to CRM)
When connecting using the URI option readPreferenceTags, I am unable to connect to a test Atlas cluster.
Environment
mongo-2.13.0 (tested with mongo-2.7.2, as well)
ruby-2.7.0
MongoDB 3.6.19
Atlas replica set: 3 electable nodes, 1 read-only node
Test program:
require 'mongo' require 'json' # mongoURI = "mongodb+srv://u:p@clegaspi-00688041.oppg5.mongodb.net/ruby?retryWrites=true" # mongoClient = Mongo::Client.new(mongoURI, :read => { :mode => :secondary, :tag_sets => [{ 'nodeType' => 'READ_ONLY'}]}) mongoURI = "mongodb+srv://u:p@clegaspi-00688041.oppg5.mongodb.net/ruby?readPreference=secondary&readPreferenceTags=nodeType:READ_ONLY" mongoClient = Mongo::Client.new(mongoURI) database = mongoClient.database collection = mongoClient[:tour] # Projection myDocument = collection.find({},{'projection' => {'_id' => 0 }}).first puts JSON.pretty_generate(myDocument) # release resources mongoClient.close
Issue
When executing the above program, I receive the following output and error:
D, [2020-09-16T00:57:32.660669 #7043] DEBUG -- : MONGODB | Topology type 'unknown' initializing. D, [2020-09-16T00:57:32.661395 #7043] DEBUG -- : MONGODB | Topology type 'Unknown' changed to type 'ReplicaSetNoPrimary'. D, [2020-09-16T00:57:32.661667 #7043] DEBUG -- : MONGODB | Server clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017 initializing. D, [2020-09-16T00:57:32.661910 #7043] DEBUG -- : MONGODB | Server clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017 initializing. D, [2020-09-16T00:57:32.662784 #7043] DEBUG -- : MONGODB | Server clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017 initializing. D, [2020-09-16T00:57:32.663568 #7043] DEBUG -- : MONGODB | Server clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017 initializing. D, [2020-09-16T00:57:32.664223 #7043] DEBUG -- : MONGODB | Waiting for up to 30.00 seconds for servers to be scanned: #<Cluster topology=ReplicaSetNoPrimary[clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017,name=atlas-n9ygcf-shard-0] servers=[#<Server address=clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017 UNKNOWN>,#<Server address=clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017 UNKNOWN>,#<Server address=clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017 UNKNOWN>,#<Server address=clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017 UNKNOWN>]> D, [2020-09-16T00:57:33.003528 #7043] DEBUG -- : MONGODB | Server description for clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017 changed from 'unknown' to 'primary'. D, [2020-09-16T00:57:33.004886 #7043] DEBUG -- : MONGODB | Topology type 'ReplicaSetNoPrimary' changed to type 'ReplicaSetWithPrimary'. D, [2020-09-16T00:57:33.005147 #7043] DEBUG -- : MONGODB | Server description for clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017 changed from 'unknown' to 'secondary'. D, [2020-09-16T00:57:33.005403 #7043] DEBUG -- : MONGODB | There was a change in the members of the 'ReplicaSetWithPrimary' topology. D, [2020-09-16T00:57:33.005653 #7043] DEBUG -- : MONGODB | Server description for clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017 changed from 'unknown' to 'secondary'. D, [2020-09-16T00:57:33.005835 #7043] DEBUG -- : MONGODB | There was a change in the members of the 'ReplicaSetWithPrimary' topology. D, [2020-09-16T00:57:33.006418 #7043] DEBUG -- : MONGODB | Waiting for up to 29.66 seconds for servers to be scanned: #<Cluster topology=ReplicaSetWithPrimary[clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017,name=atlas-n9ygcf-shard-0,v=1,e=7fffffff0000000000000001] servers=[#<Server address=clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017 PRIMARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017 SECONDARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017 SECONDARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017 UNKNOWN>]> D, [2020-09-16T00:57:33.008101 #7043] DEBUG -- : MONGODB | Server description for clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017 changed from 'unknown' to 'secondary'. D, [2020-09-16T00:57:33.008525 #7043] DEBUG -- : MONGODB | There was a change in the members of the 'ReplicaSetWithPrimary' topology. Traceback (most recent call last): 8: from QuickTour.rb:14:in `<main>' 7: from QuickTour.rb:14:in `first' 6: from /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/collection/view/iterable.rb:45:in `each' 5: from /home/ubuntu/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:235:in `read_with_retry_cursor' 4: from /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/retryable.rb:60:in `read_with_retry_cursor' 3: from /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/retryable.rb:117:in `read_with_retry' 2: from /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/retryable.rb:314:in `modern_read_with_retry' 1: from /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/retryable.rb:463:in `select_server' /home/ubuntu/.rvm/gems/ruby-2.7.0/gems/mongo-2.13.0/lib/mongo/server_selector/base.rb:272:in `select_server': No secondary server is available in cluster: #<Cluster topology=ReplicaSetWithPrimary[clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017,clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017,name=atlas-n9ygcf-shard-0,v=1,e=7fffffff0000000000000001] servers=[#<Server address=clegaspi-00688041-shard-00-00.oppg5.mongodb.net:27017 PRIMARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-01.oppg5.mongodb.net:27017 SECONDARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-02.oppg5.mongodb.net:27017 SECONDARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=clegaspi-00688041-shard-00-03.oppg5.mongodb.net:27017 SECONDARY replica_set=atlas-n9ygcf-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>]> with timeout=30, LT=0.015 (Mongo::Error::NoServerAvailable)
This error persists if I choose a different value for readPreferenceTags such as ELECTABLE. The error persists even when using the non-SRV connection string. It does not persist with only readPreference specified. It does not persist and successfully connects when the readPreference and readPreferenceTags are moved into the driver options (see the commented-out lines in the sample program).
This feels like a URI parsing issue, possibly with the ":" character in the key-value pair for the tag.
- duplicates
-
RUBY-2346 Tag names are downcased when given in URI options
- Closed