This feature would provide the option to request a graceful shutdown of mongos. Its behavior is outlined below:
- the client sends a request to a mongos that forwards the query to mongodb
- when mongos receives a specific signal (like SIGTERM), all heartbeats return an error to the client
- the client removes that mongos from the available mongos pool and does not send any new requests to that mongos
- mongos waits until all old queries are done without accepting new ones
- mongos now is free to shut down itself
In the fourth item, mongos could wait endlessly, so a timer can force the shutdown aggressively to avoid stall state.
Is it possible to shutdown mongos daemon gracefully? Which signal I should launch to the process?
Thinking about a mongos that has received a query. While the mongodb calculates the query, the mongos can be stopped. If mongos is stopped, the client driver (like nodejs does) returns a socket error.
This mean that the client is not able to know if the query runs successfully or not.
In a write context is a problem. A socket error is undetermined state.