Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongo server is stop, Reconnect Increase delay #208

Open
panzixin39 opened this issue Jan 7, 2019 · 7 comments
Open

mongo server is stop, Reconnect Increase delay #208

panzixin39 opened this issue Jan 7, 2019 · 7 comments

Comments

@panzixin39
Copy link

mc_worker.erl
init()->
......
Error ->
receive after 3000 -> ok end, %%add
proc_lib:init_ack(Error)
end.

@comtihon
Copy link
Owner

comtihon commented Jan 7, 2019

why should we wait after error was detected?

@panzixin39
Copy link
Author

Control the frequency of reconnection,Reducing CPU Occupancy

@comtihon
Copy link
Owner

comtihon commented Jan 8, 2019

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.

@panzixin39
Copy link
Author

Reconnection requires delay。Where to change, you are free

@comtihon
Copy link
Owner

comtihon commented Jan 8, 2019

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.

@comtihon
Copy link
Owner

comtihon commented Jan 8, 2019

I think reconnect with delay is useful, but I can't promise I'll have a time implementing this in the nearest future.

@panzixin39
Copy link
Author

ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants