-1

I run a project .NET have Quazrt Job in dev.azure. My job query and insert/update data in mysql db I got an error is:

job executesqljob failed with exception: parameters: refire = false, unschedulefiringtrigger = false, unschedulealltriggers = false 
 quartz.jobexecutionexception: job threw an unhandled exception.
 ---> quartz.schedulerexception: job threw an unhandled exception.
 ---> system.net.sockets.socketexception: connection reset by peer
   at mysqlconnector.protocol.serialization.socketbytehandler.writebytesasync(arraysegment  data, iobehavior iobehavior) in c:\projects\mysqlconnector\src\mysqlconnector\protocol\serialization\socketbytehandler.cs:line 90
--- end of stack trace from previous location where exception was thrown ---
   at mysqlconnector.utilities.valuetaskextensions.continuewith[t,tresult](valuetask valuetask, func continuation) in c:\projects\mysqlconnector\src\mysqlconnector\utilities\valuetaskextensions.cs:line 8
   at mysqlconnector.core.serversession.tryasynccontinuation(task task) in c:\projects\mysqlconnector\src\mysqlconnector\core\serversession.cs:line 1149
   at system.threading.tasks.continuationresulttaskfromresulttask.innerinvoke()
   at system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state)
--- end of stack trace from previous location where exception was thrown ---
   at system.threading.tasks.task.executewiththreadlocal(task& currenttaskslot)
--- end of stack trace from previous location where exception was thrown ---
   at mysqlconnector.core.textcommandexecutor.executereaderasync(string commandtext, mysqlparametercollection parametercollection, commandbehavior behavior, iobehavior iobehavior, cancellationtoken cancellationtoken) in c:\projects\mysqlconnector\src\mysqlconnector\core\textcommandexecutor.cs:line 72
   at mysql.data.mysqlclient.mysqlcommand.executedbdatareader(commandbehavior behavior) in c:\projects\mysqlconnector\src\mysqlconnector\mysql.data.mysqlclient\mysqlcommand.cs:line 168
   at microsoft.entityframeworkcore.storage.internal.relationalcommand.execute

Can one help me, please, thank so much!

enter image description here

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108

1 Answers1

1

"connection reset by peer" means that the other end of the network connection (Azure Database for MySQL, or whatever you are using as a MySQL server) has closed the connection: https://stackoverflow.com/a/1434506/23633

You should check your server logs for clues as to why this might be happening. It may be that your wait_timeout setting is lower than ConnectionIdleTimeout in your connection string, so idle connections are being kept open in the pool (on the client) longer than the server is letting them live.

Secondly, all networks are unreliable, so you should use Polly or similar to implement a retry policy around your use of EF.Core to try executing commands multiple times before failing.

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108