-
Notifications
You must be signed in to change notification settings - Fork 245
fix: remove readPreferenceTags for database&collection lookups if the cluster is sharded and readPreferenceTags was set COMPASS-9111 #6818
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
Conversation
… if readPreferenceTags was set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only suggestion might be to add a comment referencing the COMPASS ticket just so if somebody in the future wonders why we do this, they have a way of reading the related conversations, but that's definitely optional
|
I added a comment near the code that references the ticket and I also added a test that uses an actual sharded database. It isn't exactly the same as the situation in the ticket since there are no secondaries and no nodes with the ANALYTICS tag in that setup, but it does recreate the situation where those database operations would timeout because it does not know about any nodes that match the tags. |
|
Oh and if anyone ever wants to run the sharded docker image on an apple silicon mac: |
There's a bug https://jira.mongodb.org/browse/PRODTRIAGE-3102 where readPreferenceTags does not work with config servers. This means that if compass connects to a sharded cluster and then the user specifies something like
readPreferenceTags=nodeType:ANALYTICSas part of the connection string, Compass won't be able to list the databases&collections which should appear in the sidebar.The workaround here is to remove the tags for those commands IF we're connected to a sharded cluster AND readPreferenceTags is present.
To test this it is almost enough to just connect to any sharded cluster without any special node tags and then specify readPreferenceTags, but in that case no command will work because there aren't nodes for that cluster. If a node exists with the read preference tag then it would only be the database/collection lookups that don't work.
To test this manually, I used mongodb-runner:
(number of shards is probably irrelevant)
which prints the connection string, but then in order to configure sharding you have to connect to a shard manually (I found a port to connect to by just doing
ps aux | grep mongos)In my case something like
mongosh "127.0.0.1:58109"Then in mongosh:
Then connect to the URL you got from mongodb runner, but with some parameters added. In my case:
Then on compass
mainyou'll see that loading the databases/collections in the sidebar hangs until it times out.With this branch you'll see that the collections load as expected.