Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Conversation

@Anemy
Copy link
Member

@Anemy Anemy commented Dec 16, 2020

This PR is #282 just without the many package-lock.json changes, since those probably have some unintended consequences in Compass.

Here's the copy pasted description from that one.

In 3.6.3 the driver updated how operations are run so that operations which have the aspect WRITE_OPERATION default to primary instead of using the connection's readPreference:
mongodb/node-mongodb-native@ddcd03d

This PR updates our use of the db.command function which is one of those operations with the aspect WRITE_OPERATION to explicitly pass the readPreference which the user set up in Compass. This makes it so we have the same behavior as before and previous direct connections to secondaries don't suddenly stop working.

I think we could do a lot of cleanup here. I'm also not quite sure why we're using db.command for listing databases instead of db.listDatabases. This should fix the issue though. We also shouldn't be reaching into db.s.readPreference. I can create a tech debt ticket 🤔

I'm not sure if anywhere else in our codebase we rely on db.command follow the readPreference of the connection, so I'm looking into that.

Connecting and looking at data in a secondary with a direct connection:
Screen Shot 2020-12-15 at 12 33 00 PM

@Anemy Anemy merged commit 889fa77 into master Dec 16, 2020
@Anemy Anemy deleted the COMPASS-4539/pass-read-preference-with-db-command-2 branch December 16, 2020 07:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants