简体   繁体   English

node js应用程序中的knex迁移错误

[英]knex migration error in node js app

I am using knew to connect with postgres in my application.我正在使用知道在我的应用程序中连接 postgres。 I am getting following error when I run运行时出现以下错误

knex migrate:latest

TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
    at Timeout._onTimeout 

Referring some thread , I understand that I have to add transacting call but Do I need to add in all the sql calls of my app ?参考一些线程,我知道我必须添加事务调用,但是我是否需要添加应用程序的所有 sql 调用?

In documentation , It do not give me details about when to add this ?文档中,它没有提供有关何时添加此内容的详细信息? why is must ?为什么是必须的? My queries are mostly of type "GET", hence not sure if those queries needs to apply transacting?我的查询主要是“GET”类型,因此不确定这些查询是否需要应用交易?

It seems a library bug, probably.这似乎是一个库错误,可能。

Generally speaking, any behaviors including SELECT also need a transaction with read locking.一般来说,包括 SELECT 在内的任何行为也需要一个带有读锁定的事务。 DB will organize the resource locking sequence according to the transaction isolation level setting and mostly READ COMMITTED is default. DB 将根据事务隔离级别设置组织资源锁定顺序,并且大多数READ COMMITTED是默认值。 Rows in a table cannot be deleted while a user is reading it until finished the action.在用户阅读表时,表中的行不能删除,直到完成操作。 Delete (exclusive locking) waits until the Select (read shared lock) release it, even if we didn't mention a begin transaction.即使我们没有提到开始事务,Delete(排他锁)也会等到 Select(读共享锁)释放它。

In this reason, most of the database connection libraries are supporting "auto commit" option like this , this and this to automatically wrap with a transaction by default if there is no explicit transaction made (or supported by the DBMS session option natively), so all the request run on a transaction block.在这个原因,大多数数据库连接库都支持“自动提交”像选择这个这个这个自动与交易默认包装是否有作出(或由本地的DBMS session选项支持),没有明确的交易,所以所有请求都在一个事务块上运行。

Knex seems not have this option explicitly. Knex 似乎没有明确的这个选项。 I can find it may differ to the DBMS types.我发现它可能与 DBMS 类型不同。 Oracle dialect . 甲骨文方言 While reading the code, I found Oracle implementation have it here but Postgresql implementation here does not have auto commit.在阅读的代码,我发现Oracle实施有它在这里,但PostgreSQL里的实现在这里没有自动提交。 It looks incomplete to me.对我来说它看起来不完整。

The document also says it could select query without transacting call.该文件还说它可以在不处理呼叫的情况下选择查询。 If it leaks many open session, then it's obviously a bug.如果它泄漏了许多打开的会话,那么它显然是一个错误。 Please file a bug report with a sample code to reproduce this issue.请使用示例代码提交错误报告以重现此问题。

Or you could inspect what queries in the pending list from the database side.或者您可以从数据库端检查待处理列表中的哪些查询。 All the modern database system could list up the sessions and locking status.所有现代数据库系统都可以列出会话和锁定状态。 I suppose you have mixed with the naive select call and the transacting() call and then the naive select calls may appended to an uncommitted open transaction.我想你已经混合了 naive select 调用和 transacting() 调用,然后naive select 调用可能会附加到未提交的打开事务中。 You can watch what is happening from the DB admin feature like this .你可以看什么是从像数据库管理功能发生

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM