devinus / poolboy

A hunky Erlang worker pool factory
http://github.com/devinus/poolboy
ISC License
1.56k stars 348 forks source link

epgsql example doesn't recover gracefully from postgresql restarts #63

Closed hce closed 9 years ago

hce commented 9 years ago

I've used the epgsql pool example from your readme. I don't understand why you are trapping the exit signal in the pgsql_connection worker. If I remove that line, a restart/full stop of postgres is detected and results in the whole application being shut down. If, OTOH, I keep the line, the next time a process queries the database, that process will crash. I don't know if that's intended behaviour, but the behaviour I would expect is that processes using an epgsql pool crash only if they submitted a faulty query or if the database server crashed at the very moment of the request.

Related question: Do you have a suggestion to prevent the whole supervisor/application from shutting down when the database is restarted? I am not sure about weather/where to introduce a delay in the code.

devinus commented 9 years ago

@hce Yes, that example is a very simple example just to showcase how Poolboy works. Every worker needs to be written with it's specific use case taken into consideration. For epgsql, something closer to https://github.com/interline/epgsql_pool/blob/master/src/epgsql_pool_worker.erl that detects when the worker has a connection and acts appropriately needs to be used.