mongodb-erlang
mongodb-erlang copied to clipboard
mongo server is stop, Reconnect Increase delay
mc_worker.erl init()-> ...... Error -> receive after 3000 -> ok end, %%add proc_lib:init_ack(Error) end.
why should we wait after error was detected?
Control the frequency of reconnection,Reducing CPU Occupancy
I think some top supervisor should be responsible for worker restart delay. Not the worker itself, as it know nothing about will it be restarted or not.
Reconnection requires delay。Where to change, you are free
it is not supported out of the box. There are several options:
- You should use your own supervisor, have mc_worker be a child and restart it with backoff (can be increment). You can try something ready like this or this
- use standard supervisor, but custom start function - wrapper around mc_worker with try-catch and your delay code. I think it is the easiest and the fastest solution.
- use standard supervisor + standard worker, but without reconnect. Use your monitor process, which will monitor the pool and shoot a timed restart (start new worker actually) if error encountered.
I think reconnect with delay is useful, but I can't promise I'll have a time implementing this in the nearest future.
ok.