Sail.js启动多个连接 [英] Sail.js multiple connections on start
问题描述
编辑:
创建连接到Postgresql:错误:太多角色连接
xwoellnkvjcupt
创建到Postgresql的连接时出错:错误:连接过多的角色
xwoellnkvjcupt
错误:挂钩未能加载:orm(错误:太多的角色连接xwoellnkv
jcupt)
错误:加载Sails核心时遇到错误!
错误:错误:在Connection.parseE上的角色xwoellnkvjcupt
的连接太多(C:\Studia\szachman2\\\
ode_modules\sails-postgresql\\\
ode
_modules\\ \\pg\lib\connection.js:561:11)在Connection.parseMessage处的
(C:\Studia\szachman2\\\
ode_modules\sails-postgresq
l\\\
ode_modules\pg \lib\connection.js:390:17)
at null。 (C:\Studia\szachman2\\\
ode_modules\sails-postgresql\\\
ode_
modules\pg\lib\connection.js:98:18)在CleartextStream.EventEmitter上
。在CleartextStream发出(events.js:95:17)
。 (_stream_readable.js:746:14)
at CleavedExtStream.EventEmitter.emit(events.js:92:17)
at emitReadable_(_stream_readable.js:408:10)
at _stream_readable。 js:401:7
at process._tickDomainCallback(node.js:459:13)
这是我经常在尝试测试时遇到的错误新的代码在本地主机上。
@jantar @ sgress454我刚刚在 sails-postgresql
中添加了一条故障排除信息,尝试使其更好。以下是它的内容:
- > 也许您的
poolSize
配置为设置得太高?例如如果你的Postgresql数据库只支持20个并发连接,你应该确保你的poolSize
设置为< 20.默认poolSize
为10。
覆盖默认的
poolSize
,在相关的Postgresql连接配置对象上指定一个poolSize
属性。如果您使用的是Sails,它通常位于config / connections.js
中,或者设置了特定于环境的数据库配置。
- > 您是否有多个共享相同Postgresql数据库的Sails实例?每个Sails实例最多可以使用配置的
poolSize
连接数量。假设所有的Sails实例只是彼此的副本(一个合理的最佳实践),我们可以通过乘以配置的poolSize
来计算实际使用的Postgresql连接数(C)( P)乘以Sails实例的数量(N)。如果连接的实际数量(C)超过了Postgresql数据库(V)的 AVAILABLE 连接总数,那么您遇到了问题。如果这适用于您,请尝试减少您的poolSize
配置。合理的poolSize
设置为V / N。
I've got an odd problem - on start of my sails app (which is connecting with postgres and deployed on heroku ) there are multiple connections (around 10) to database, and since it's free account, if I then try to launch app on localhost to test some new code I get an error "too many connections for a role". So does anyone know why there are so many connections to database and can I change it, to have only one connection per app?
EDIT: Error creating a connection to Postgresql: error: too many connections for role "xwoellnkvjcupt" Error creating a connection to Postgresql: error: too many connections for role "xwoellnkvjcupt" error: Hook failed to load: orm (error: too many connections for role "xwoellnkv jcupt") error: Error encountered while loading Sails core! error: error: too many connections for role "xwoellnkvjcupt" at Connection.parseE (C:\Studia\szachman2\node_modules\sails-postgresql\node _modules\pg\lib\connection.js:561:11) at Connection.parseMessage (C:\Studia\szachman2\node_modules\sails-postgresq l\node_modules\pg\lib\connection.js:390:17) at null. (C:\Studia\szachman2\node_modules\sails-postgresql\node_ modules\pg\lib\connection.js:98:18) at CleartextStream.EventEmitter.emit (events.js:95:17) at CleartextStream. (_stream_readable.js:746:14) at CleartextStream.EventEmitter.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:408:10) at _stream_readable.js:401:7 at process._tickDomainCallback (node.js:459:13)
this is an error I am getting often when trying to test some new code on localhost.
@jantar @sgress454 I just added a troubleshooting message in sails-postgresql
to try and make this better. Here's what it says:
-> Maybe your
poolSize
configuration is set too high? e.g. If your Postgresql database only supports 20 concurrent connections, you should make sure you have yourpoolSize
set as something < 20. The defaultpoolSize
is 10.To override the default
poolSize
, specify apoolSize
property on the relevant Postgresql "connection" config object. If you're using Sails, this is generally located inconfig/connections.js
, or wherever your environment-specific database configuration is set.-> Do you have multiple Sails instances sharing the same Postgresql database? Each Sails instance may use up to the configured
poolSize
# of connections. Assuming all of the Sails instances are just copies of one another (a reasonable best practice) we can calculate the actual # of Postgresql connections used (C) by multiplying the configuredpoolSize
(P) by the number of Sails instances (N). If the actual number of connections (C) exceeds the total # of AVAILABLE connections to your Postgresql database (V), then you have problems. If this applies to you, try reducing yourpoolSize
configuration. A reasonablepoolSize
setting would be V/N.
这篇关于Sail.js启动多个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!