Skip to content
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

mongo: slaveOk flag should be subject to the readPreference handling #152

Open
zecke opened this issue Feb 1, 2020 · 2 comments
Open

mongo: slaveOk flag should be subject to the readPreference handling #152

zecke opened this issue Feb 1, 2020 · 2 comments

Comments

@zecke
Copy link
Contributor

zecke commented Feb 1, 2020

I was browsing VOMongoReadOneOperation>>#basicSelectOne and noticed that it sets the flag slaveOk. For strong consistency when readPreference is set to primary I prefer to not accidentally read data from a stale secondary.

At least VOMongoReadOneOperation and VOMOngoSelectManyOperation need some review.

@tinchodias WDUT?

@tinchodias
Copy link
Contributor

tinchodias commented Feb 2, 2020

Hmmm the readpreference determines which server of the replica set will receive the operation. The slaveOk=true doesn't affect if the selected server is the primary, but it is needed when the selected server is secondary (there is an error, else).

But I'm on my phone now, I will check it later to corroborate.

@zecke
Copy link
Contributor Author

zecke commented Feb 3, 2020

There is a race condition. While we think serverA is primary it might have recently moved to serverB. We can't win this race on the client. Only the servers can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants