You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pgapp_worker expects to have one child epgsql_sock which is the connection to the database. The function handle_info({'EXIT', From, Reason}, State) deals with the case when this child dies for some reason. In this case we cast reconnect and a new child epgsql_sock is created.
When using pgapp:with_transaction, the code inside the provided function is run by the pgapp_worker process. If the code inside the transaction function receives the message {'EXIT', From, Reason} (for example a spawn_linked process finishes normally) pgapp_worker will interpret this as a crash of its child epgsql_sock and it will trigger a cast to reconnect, even though the original epqgsql_sock is alive and well.
This process will cause the number of open epgsql_socks to increase forever until the database limit is reached, at which point some of the open connections will be forcefully closed.
Solution
The function handle_info({'EXIT', From, Reason}, State) should ensure that the From PID is the same as its child epgsql_sock. If it is not, then it should not attempt to reconnect.
The text was updated successfully, but these errors were encountered:
Problem
pgapp_worker
expects to have one childepgsql_sock
which is the connection to the database. The functionhandle_info({'EXIT', From, Reason}, State)
deals with the case when this child dies for some reason. In this case we cast reconnect and a new childepgsql_sock
is created.When using
pgapp:with_transaction
, the code inside the provided function is run by thepgapp_worker
process. If the code inside the transaction function receives the message{'EXIT', From, Reason}
(for example aspawn_link
ed process finishes normally)pgapp_worker
will interpret this as a crash of its childepgsql_sock
and it will trigger a cast toreconnect
, even though the originalepqgsql_sock
is alive and well.This process will cause the number of open
epgsql_sock
s to increase forever until the database limit is reached, at which point some of the open connections will be forcefully closed.Solution
The function
handle_info({'EXIT', From, Reason}, State)
should ensure that theFrom
PID is the same as its childepgsql_sock
. If it is not, then it should not attempt to reconnect.The text was updated successfully, but these errors were encountered: