Skip to content

Crash when connection to MySQL db is interrupted #20

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

Open
renblau opened this issue Dec 15, 2018 · 3 comments
Open

Crash when connection to MySQL db is interrupted #20

renblau opened this issue Dec 15, 2018 · 3 comments
Assignees

Comments

@renblau
Copy link

renblau commented Dec 15, 2018

I have noticed that all of my servers that are running the current sqljocky5 version crash from time to time. The connection to MySQL gets interrupted for whatever reason (e.g. mysqld restart). Then, when the program tries to execute a query, this happens:

Unhandled exception:
Bad state: Cannot write to socket, it is closed
#0      BufferedSocket.writeBufferPart (package:sqljocky5/comm/buffered_socket.dart:112:7)
#1      BufferedSocket.writeBuffer (package:sqljocky5/comm/buffered_socket.dart:107:12)
#2      Sender._sendBufferPart (package:sqljocky5/comm/sender.dart:57:19)
<asynchronous suspension>
#3      Sender.send (package:sqljocky5/comm/sender.dart:45:14)
<asynchronous suspension>
#4      Comm._processHandler (package:sqljocky5/comm/comm.dart:114:19)
<asynchronous suspension>
#5      Comm.execHandler.<anonymous closure> (package:sqljocky5/comm/comm.dart:120:36)
#6      new Future.sync (dart:async/future.dart:224:31)
#7      Pool.withResource.<anonymous closure> (package:pool/pool.dart:126:18)
#8      _RootZone.runUnary (dart:async/zone.dart:1379:54)
#9      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#10     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#11     Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#12     Future._completeWithValue (dart:async/future_impl.dart:483:5)
#13     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
#14     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#15     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#16     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#17     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

Furthermore, I wasn't able to catch the error to handle it myself (i.e. create a new connection and retry the query):
Edit: That was my fault, catching works fine. I guess I have to implement a reconnect mechanism into my application now.

Would be cool though if the library detected disconnects itself. Ideally before the user is trying to execute a query. Something like: _connection.onDisconnect.listen( ... )

@tejainece
Copy link
Contributor

I will fix this.

@tejainece tejainece self-assigned this Feb 15, 2019
@hoylen
Copy link

hoylen commented Feb 19, 2019

This goal is related to the "unhandled exception" reported in #26. But the specific exception is different, since I can't seem to catch the other exception (not without trying to use zones etc.).

@tejainece
Copy link
Contributor

@renblau
onDisconnect is a brilliant idea.

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

3 participants