Knex:运行“ knex migration”时超时获取连接

时间:2020-05-01 20:14:20

标签: node.js postgresql knex.js

我正在运行./node_modules/.bin/knex migrate:latest --env local

这将导致以下错误:

> knex migrate:latest --env local

Requiring external module ts-node/register
Using environment: local
TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
at /Users/ashok/src/super-abs/alpha/server/node_modules/knex/lib/client.js:318:17
    at tryCatcher (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/catch_filter.js:17:41
    at tryCatcher (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/ashok/src/super-abs/alpha/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

我什至尝试删除数据库并重新运行。

我需要以某种方式清除连接吗?我的应用程序未运行。

使用以下内容

"knex": "0.19.0",

节点-v:v14.0.0

psql (PostgreSQL) 11.7

2 个答案:

答案 0 :(得分:0)

通过简单地降级到节点版本13.11.0来解决此问题:

sudo npm install -g n
sudo n 13.11.0
knex migrate:latest
#  Requiring external module ts-node/register
#  Using environment: local
#  Batch 1 run: 63 migrations

是的

答案 1 :(得分:0)

Knex: Timeout acquiring a connection. The pool is probably full...

升级pg@8.3.0解决了该问题。
环境:
节点14.6
pg:7.8
“ knex”:“ ^ 0.20.10”,

https://github.com/knex/knex/issues/3912
https://github.com/knex/knex/issues/3912#issuecomment-657715661

相关问题