首页 > 编程知识 正文

nodejs查询mysql,node高并发更新mysql

时间:2023-05-04 20:59:29 阅读:18037 作者:4244

I ' mrunninganodeserverconnectingtomysqlviathenode-MySQL module.connectingtoandqueryingmysqlworksgreatinitiallywithoutanyeratanyeryer thefirstqueryafterleavingthenodeserveridleforacouplehoursresultsinanerror.therroristhefamiliarreadeconnreset,however,therrred

astacktrace (notethatthethreeentriesofthetracebelongtomyapp ' serrorreportingcode ) :

错误发生器

at exports.error.utils.create class.init (d : (site (ww root (errors.js 3360180:16 ) ) )。

atnewnewclass (d : (home (site (wwwroot ) utils.js336068:14 ) )。

at query._ callback (d : (home (site ) wwroot ) db.js:281:21 ) )。

at query.sequence.end (d :homesiteww rootnode _ modulesMySQLlibprotocolsequ sencesse )

at protocol.handlenetworkerror (d :homesitewwwrootnode _ modulesMySQLlibprotocolprotocol

atpool connection.connection._ handlenetworkerror (d :homesiteww rootnode _ modules _ MySQLlib )

at socket.event emitter.emit (events.js :95336017 ) )。

at net.js:441:14

at process._ tick callback (node.js :415336013 )。

thiserrorhappensbothonmycloudnodeserverandmysqlserveraswellasalocalsetupofpsdbks/pmy questions 3360

doesthisproblemappeartobeadisconnectionofnode ' sconnectiontomymysqlserver (s,perhapsduetoaconnectionlifetimelimitation?

When using connection pools,node-mysqlissupposedtogracefullyhandledisconnectionsandprunethemfromthepool.isitnotawareofthedidiol

consideringthatiseethe ' readeconnreset ' erroralotinotherstackoverflowposts,shouldibelookingelsewherefrommmysqltodiagnosethe

Update: After more browsing,ithinkmyissueisaduplicateofthisone.itappearshisconnectionisdisconnectingaswell, butnoonehassuggestedhowtokeeptheconnectionaliveorhowtoaddresstheerroroutsideoffailingonthefirstqueryback。

解决方案

ireachedouttothenode-mysqlfolksontheirgithubpageandgotsomefirmanswers。

According to this issue, 节点- MySQL doesn ' tprunepoolconnectionsafterthesesortsofdisconnections.themoduledevelopersrecommendedusingaheartbeattokep dedusingthenode-poolmoduleanditsidletimeoutmillisoptiontoautomaticallypruneidleconnections。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。