V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
plantain
V2EX  ›  问与答

nodejs 网站正常运行一段时间后,突然所有需要访问数据库的接口都没有响应(其它接口都正常),日志里也没有记录任何错误,而通过 mysql client 可以正常连接这个数据库。这种一般是那方面的问题?

  •  
  •   plantain · Aug 15, 2015 · 3751 views
    This topic created in 3910 days ago, the information mentioned may be changed or developed.
    蛋疼的是,刚才重启了网站,结果现在重现不了了。

    我是用node-mysql的数据库连接池来访问数据库的。
    5 replies    2015-08-15 22:32:08 +08:00
    oott123
        1
    oott123  
       Aug 15, 2015
    既然你都提到了连接池……
    我猜连接池里的连接耗光了呗。

    翻了下文档,你确定你用了 `connection.release();` 来释放连接池吗?
    oott123
        2
    oott123  
       Aug 15, 2015
    * 释放连接
    ytzong
        3
    ytzong  
       Aug 15, 2015
    http://www.99css.com/vps-and-nodejs/ 修改一下 MySQL 的配置
    phoenixlzx
        4
    phoenixlzx  
       Aug 15, 2015
    我之前也遇到过,我说用连接池的话如果有 MySQL 自动断开,连接池不会自动 handle。

    https://github.com/felixge/node-mysql/issues/652

    然而似乎大家都坚持认为 pool 会自动处理,但是无论如何我都没搞得定自动断开后的处理问题。
    最后的选择是放弃 mysql 改用 mongodb(死
    plantain
        5
    plantain  
    OP
       Aug 15, 2015
    @oott123 网站已经正常连续运行了好几天,处理了上万次数据库操作,如果没有release连接,pool早就空了。
    下周,我打算监视一下数据库操作前的连接数变化,看看是不是有低频率的代码忘了release连接。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3005 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:58 · PVG 22:58 · LAX 07:58 · JFK 10:58
    ♥ Do have faith in what you're doing.