egg-sequelize连接池不能释放问题
发布于 6 年前 作者 zhangmingfeng 5517 次浏览 来自 问答

egg项目使用egg-sequelize作为orm框架,该项目使用的mysql数据库和另外一个项目在一起,只是库不同而已,另外一个项目在做压力测试的时候将数据库cpu使用率提高到150%,持续时间挺长的。后来发现egg项目这边请求数据库老是超时,即使mysql数据库恢复正常之后,依然超时,重启egg项目之后才恢复正常,感觉就是连接池里的连接全部失效了而没有释放。想问问大家有没有遇到同样的问题,下面是错误信息和sequelize插件的配置:

2018-10-25 09:01:22,923 ERROR 15972 Fatal error: ResourceRequest timed out, ctx: {"request":{"method":"POST","url":"/dcc/v1/quota/get","header":{"host":"dccs.bw-xt.com","x-real-ip":"XXX","x-forwarded-for":"XXX","connection":"close","content-length":"176","user-agent":"Needs Clouds Client 5.0","accept":"*/*","content-type":"application/json;charset=utf-8"}},"response":{"status":404,"message":"Not Found","header":{"vary":"Origin"}},"app":{"env":"prod","name":"needs_dccs","baseDir":"/srv/www/vhosts/Needs_Dccs","subdomainOffset":2,"config":"<egg config>","controller":"<egg controller>","httpclient":"<egg httpclient>","loggers":"<egg loggers>","middlewares":"<egg middlewares>","router":"<egg router>","serviceClasses":"<egg serviceClasses>"},"originalUrl":"/dcc/v1/quota/get","req":"<original node req>","res":"<original node res>","socket":"<original node socket>"}
2018-10-25 09:01:31,620 ERROR 15996 [-/127.0.0.1/-/30005ms POST /dcc/v1/quota/get] nodejs.TimeoutError: ResourceRequest timed out
    at ResourceRequest._fireTimeout (/srv/www/vhosts/Needs_Dccs/node_modules/generic-pool/lib/ResourceRequest.js:62:17)
    at Timeout.bound (/srv/www/vhosts/Needs_Dccs/node_modules/generic-pool/lib/ResourceRequest.js:8:15)
    at ontimeout (timers.js:427:11)
    at tryOnTimeout (timers.js:289:5)
    at listOnTimeout (timers.js:252:5)
    at Timer.processTimers (timers.js:212:10)
name: "TimeoutError"
sequelize: {
            dialect: 'mysql',
            database: 'database',
            username: 'root',
            password: 'password',
            timezone: '+08:00',
            host: '127.0.0.1',
            port: '3306',
            loggerLevel: 'debug',
            dialectOptions: {
                supportBigNumbers: true,
                bigNumberStrings: true
            },
            define: {
                freezeTableName: true,
                charset: 'utf8',
                dialectOptions: {
                    collate: 'utf8_general_ci'
                },
                timestamps: false
            },
            pool: {
                max: 5,
                min: 0,
                acquire: 30000,
                idle: 10000
            }
        },
2 回复

自顶一下,没人遇到过吗?

来自酷炫的 CNodeMD

@zhangmingfeng 你好 现在个问题解决了吗 看了一下 官方文档 貌似也没解决方案

回到顶部