我运行一个项目。NET在dev.azure中有Quazrt Job。我的作业查询和在mysql db中的插入/更新数据我得到一个错误是:
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
请帮助我,非常感谢!
“对等方的连接重置”表示网络连接的另一端(MySQL的Azure数据库,或您用作MySQL服务器的任何对象)已关闭连接:https://stackoverflow.com/a/1434506/23633
您应该检查服务器日志以获取有关为什么可能发生这种情况的线索。可能是您的wait_timeout
设置低于连接字符串中的wait_timeout
,所以空闲连接在客户端池中保持打开状态的时间长于服务器允许它们存活的时间。
第二,所有网络都不可靠,因此您应该使用ConnectionIdleTimeout
或类似的方法围绕EF.Core的使用实施重试策略,以在失败之前尝试多次执行命令。