sqlalchemy-rqlite icon indicating copy to clipboard operation
sqlalchemy-rqlite copied to clipboard

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

Open lkxjtu opened this issue 7 years ago • 5 comments

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?

lkxjtu avatar Aug 02 '17 07:08 lkxjtu

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.

zmedico avatar Aug 02 '17 15:08 zmedico

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)

lkxjtu avatar Aug 06 '17 15:08 lkxjtu

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 avatar Sep 17 '17 19:09 zmedico

https://github.com/rqlite/pyrqlite/commit/e0395b3ffc3bd6820aecdbffdeae61a47e581a0f fixes pyrqlite to re-open the connection in case of server restart.

zmedico avatar Sep 17 '17 19:09 zmedico

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.

zmedico avatar Sep 17 '17 20:09 zmedico