globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

Not checking "not master" and "node is recovering" errors #309

Open IvanVlasic opened 5 years ago

IvanVlasic commented 5 years ago

During compact of one of our secondaries I noticed that there was period of few seconds when queries would return error "node is recovering".

Checking mongo specification on server discovery and monitoring I noticed part about handling those kinds of errors as seen here.

Multi-threaded and asynchronous clients MUST request an immediate check of the server. Unlike in the "network error" scenario above, a "not master" or "node is recovering" error means the server is available but the client is wrong about its type, thus an immediate re-check is likely to provide useful information.

Checking through the code I don't think that this type of check is currently implemented which can result in above mentioned behaviour.

maitesin commented 5 years ago

Hi @IvanVlasic

Can you provide an example to reproduce this behaviour? Moreover, contributions are welcomed, so it would be great if you are willing to open a PR!

Best regards, Oscar

IvanVlasic commented 5 years ago

Hello @maitesin, thanks for getting back to me.

I will try to write some tests and possibly open a PR once I get some free time for this.