mpihlak / mongoproxy

Lightweight proxy to collect MongoDb client metrics
MIT License
42 stars 8 forks source link

Restore ordering by having tracker alternate between client and server messages #43

Closed mpihlak closed 1 week ago

mpihlak commented 2 weeks ago

With async proxy and parse loop the messages can arrive at the tracker out of order. Solve this by having the tracker assume that the conversation is always client -> server.

This doesn't support the server initiated conversations (ie. multiple helloOk responses to a single hello from client), but at the moment there is no support for counting these anyway.

If the server starts to speak on its own the tracker will remain blocked waiting for a client message. In turn this causes the try_send to fail at the proxy level and disable tracking. Proxying will continue to work and this will keep clients happy (ie. otherwise Mongoose would reconnect).