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

After rqlite server restart, sqlalchemy-rqlite can not reconnect to server #4

Open
lkxjtu opened this issue Aug 2, 2017 · 5 comments

Comments

@lkxjtu
Copy link

lkxjtu commented Aug 2, 2017

My python code
engine = create_engine('rqlite+pyrqlite://localhost:4001/')
At the beginning, it can work properly. When I restart rqlited, the engine becomes unavailable.Until I run create_engine again, it work properly. Is this a issue?

@zmedico
Copy link
Collaborator

zmedico commented Aug 2, 2017

It sounds like we need to give pyrqlite the ability to reconnect automatically. Do you know if some kind of exception is raised when it stops working? An exception would be a useful way to know when re-connection is necessary.

@lkxjtu
Copy link
Author

lkxjtu commented Aug 6, 2017

Sorry I can't catch the exception when rqlited restart. When I log str(e), it show '' only, I don't know why.I circumvent this problem by unusing connection pool
engine = create_engine('rqlite+pyrqlite://localhost:4001/', poolclass=NullPool)

@zmedico
Copy link
Collaborator

zmedico commented Sep 17, 2017

I've tested using the pyrqlite api directly, and I see multiple failure modes that vary depending on the python version.

For Python 2.7.12, I observed httplib.CannotSendRequest from HTTPConnection.request(), and httplib.BadStatusLine from HTTPConnection.getresponse().

For Python 3.6.1, I observed BrokenPipeError from HTTPConnection.request(), http.client.CannotSendRequest from HTTPConnection.request(), and http.client.RemoteDisconnected from HTTPConnection.getresponse().

@zmedico
Copy link
Collaborator

zmedico commented Sep 17, 2017

rqlite/pyrqlite@e0395b3 fixes pyrqlite to re-open the connection in case of server restart.

@zmedico
Copy link
Collaborator

zmedico commented Sep 17, 2017

We may want to add a pyrqlite connection parameter to control timeout.

Also, it would be better if pyrqilte raised an exception derived from its base Error class, and used exception chaining to indicate the underlying cause.

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