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

Temporary close permanently stops mysql access #164

Open
Lazarus404 opened this issue May 1, 2015 · 3 comments
Open

Temporary close permanently stops mysql access #164

Lazarus404 opened this issue May 1, 2015 · 3 comments

Comments

@Lazarus404
Copy link

Hi,

So, I've been running an app I wrote for some time, and this app breaks via emysql. After a number of hours of running, I get this in the erlang logs:

application: emysql
exited: stopped
type: temporary

Once this happens, no more writes to mysql occur and the app essentially breaks. I have a gen_server which creates the mysql pool in its init function, and looks something like this:

init([
    {
        MHostName,
        MPort,
        MUser,
        MPassword,
        MDatabaseName
    } ->
    application:start(emysql),
    emysql:add_pool(auth_pool, 10,
        MUser, MPassword, MHostName, MPort,
        MDatabaseName, utf8).

Then, in each handle_info function, I do a simple emysql stored procedure call, like:

emysql:execute(auth_pool, erlang:list_to_binary(Query))

Is there a way to force the mysql connection to reopen on close or to at least discover if the connection is closed so I can force the gen_server to kill itself abnormally?

Thanks,
Lee

@jlouis
Copy link
Collaborator

jlouis commented May 1, 2015

I'd go look at the error log for your system. If an application stops, it is usually some grave error that happens in the application. They are not supposed to stop like that. If your application depends critically on emysql being up, you should perhaps start it as a permanent application:

application:start(emysql, permanent)

which would have killed your node once emysql fails.

@Lazarus404
Copy link
Author

Thanks for the response. I've updated the app so emysql is permanent.
Hopefully, that'll at least get the thing restarting when it's needed.
I've checked the logs on the server and there is nothing related to
emysql. This is the problem, I think. The app continues as those
emysql was still able to connect to the database. The database is on
another server, which I don't think is helping, sometimes.

I'll let you know if I'm able to dig up more.

Thanks,
Lee

On 01/05/15 12:54, Jesper Louis Andersen wrote:

I'd go look at the error log for your system. If an application stops,
it is usually some grave error that happens in the application. They
are not supposed to stop like that. If your application depends
critically on emysql being up, you should perhaps start it as a
permanent application:

|application:start(emysql, permanent)
|

which would have killed your node once emysql fails.


Reply to this email directly or view it on GitHub
#164 (comment).

@Lazarus404
Copy link
Author

No, it still ended. 3 hours after starting. It always seems to stop at about the same time after the app starts. Is there a way to check if the connection is closed via emysql so I can force the gen_server to restart?

Thanks

On 1 May 2015, at 12:54, Jesper Louis Andersen [email protected] wrote:

I'd go look at the error log for your system. If an application stops, it is usually some grave error that happens in the application. They are not supposed to stop like that. If your application depends critically on emysql being up, you should perhaps start it as a permanent application:

application:start(emysql, permanent)
which would have killed your node once emysql fails.


Reply to this email directly or view it on GitHub #164 (comment).

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