coinbase / mongobetween

Apache License 2.0
119 stars 48 forks source link

Drivers could mark mongobetween Unknown for server issues #16

Open divjotarora opened 4 years ago

divjotarora commented 4 years ago

The README says that mongobetween appears as an always-available mongos server, but I believe a driver would mark mongobetween as Unknown if there were a server error like NotMaster. In this case, mongobetween would extract the error and use the Go driver's ProcessError function to mark the actual mongos Unknown, which is correct, but would also proxy the message back to the original driver, which would then mark mongobetween Unknown per the error handling section of the SDAM spec.

EDIT: I think the same is true for connection errors. mongo.RoundTrip returns an error if the WriteWireMessage or ReadWireMessage calls fail. This is propagated upward so handleConnection returns the error to the goroutine launched by Proxy.accept, which closes the connection. This would show up in the application as a non-timeout network error, which would cause the application to mark the proxy as Unknown and clear its connection pool.