Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

think-mysql 升级到 1.4.0 线上经常卡死 #1372

Closed
arterli opened this issue May 8, 2019 · 16 comments
Closed

think-mysql 升级到 1.4.0 线上经常卡死 #1372

arterli opened this issue May 8, 2019 · 16 comments

Comments

@arterli
Copy link

arterli commented May 8, 2019

DESC

think-mysql 升级到 1.4.0 线上经常卡死,

ENV

OS Platform:

Node.js Version:

ThinkJS Version:

code

// your code here

error message

// your error message here
[2019-05-08T00:29:04.997] [ERROR] default - unhandledRejection, times: 1, pid: 31765
[2019-05-08T00:29:04.997] [ERROR] default - Error: cannot create more connection in transation, use db() to reuse connection!
    at ThinkMysql.getConnection (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:78:29)
    at debounceInstance.debounce (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:225:21)
    at Promise.resolve.then (/www/wwwroot/yyfzx/node_modules/think-debounce/index.js:19:16)
[2019-05-08T00:29:04.997] [ERROR] default - Error: cannot create more connection in transation, use db() to reuse connection!
    at ThinkMysql.getConnection (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:78:29)
    at debounceInstance.debounce (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:225:21)
    at Promise.resolve.then (/www/wwwroot/yyfzx/node_modules/think-debounce/index.js:19:16)
[2019-05-08T00:34:45.043] [ERROR] default - unhandledRejection, times: 2, pid: 31765
[2019-05-08T00:34:45.043] [ERROR] default - Error: cannot create more connection in transation, use db() to reuse connection!
    at ThinkMysql.getConnection (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:78:29)
    at debounceInstance.debounce (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:225:21)
    at Promise.resolve.then (/www/wwwroot/yyfzx/node_modules/think-debounce/index.js:19:16)
[2019-05-08T00:34:45.043] [ERROR] default - Error: cannot create more connection in transation, use db() to reuse connection!
    at ThinkMysql.getConnection (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:78:29)
    at debounceInstance.debounce (/www/wwwroot/yyfzx/node_modules/think-mysql/index.js:225:21)
    at Promise.resolve.then (/www/wwwroot/yyfzx/node_modules/think-debounce/index.js:19:16)

more description

// your detail description

@luckyscript
Copy link

可以贴一下你事务相关的代码么?事务里面需要用db()来复用连接。#1334

@arterli
Copy link
Author

arterli commented May 8, 2019

都检查了几十遍了,而且是相同的业务代码,以前没有任何问题,自从升级到think-mysql 1.4.0,就开始出现。绝对不是db()复用的问题

@arterli
Copy link
Author

arterli commented May 8, 2019

而且每天都会卡住。都升级了些啥啊。

@arterli
Copy link
Author

arterli commented May 8, 2019

有部分客户还没又升级的,用的是 think-mysql 1.2.5 出现任何问题,升级的,每天都卡住。相同的代码。

@arterli
Copy link
Author

arterli commented May 8, 2019

哥们我怎么退回去,并且指定用1.2..5,这不是坑人吗,几百客户,的收银台,天天卡住。都疯了。

@lizheming
Copy link
Contributor

MySQL 的配置提供下吧,把关键信息过滤一下。

@arterli
Copy link
Author

arterli commented May 8, 2019

云数据库的配置?

@lizheming
Copy link
Contributor

lizheming commented May 8, 2019

@arterli 想看一下你有没有配线程池相关的配置。你如果确认 think-mysql@1.2.5 这个版本没有问题的话,可以上机器强制 npm install think-mysql@1.2.5 然后重启下服务就可以了。我后续再看看这块的逻辑。

@arterli
Copy link
Author

arterli commented May 8, 2019

@lizheming 好,因为是自动安装,自动安装会用安装最新版的依赖,所以新安装的1.4.0的,都出问题了,上百个呢,我先一个一个恢复到 1.2.5

@lizheming
Copy link
Contributor

@arterli 已经安装了的话没太多办法,写个批量脚本执行下吧。我们尽快看下这个问题,具体QQ沟通。

@bravecat
Copy link

一个事务未完成时,开启另一个事务会报错。cannot create more connection in transation, use db() to reuse connection! 。例如用下面代码,在5秒内请求两次就会报错:

async indexAction() {
  const model = think.model('user')
  await model.transaction(async () => {
    /** 模拟事务需要5秒执行完成 */
    await new Promise(res => setTimeout(res, 5000))
  })
  return this.success('hello')
}

@arterli
Copy link
Author

arterli commented May 31, 2019 via email

@bravecat
Copy link

@arterli 你好,我这个例子怎么处理好呢?里面没有用到嵌套model的。

@lizheming
Copy link
Contributor

@bravecat 请提供一个最小可复现的环境,我拿着你之前给的代码在本地试了是 OK 的,具体见截图。
image
image
image

@bravecat
Copy link

bravecat commented May 31, 2019

@lizheming 你好,我测试下最新的think-mysql 1.4.2没有这个问题,1.4.0版本有,在package.json 指定安装"think-mysql": "1.4.0"即可出现(开两个窗口,其中一个无痕式窗口,在5秒内分别访问一次)。

@lizheming
Copy link
Contributor

@bravecat 新版本没有那就忽略吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants