[英]'Too many connections' created in postgres when creating a dashboard in Pentaho
I was creating a Dashboard in Pentaho PUC which uses a postgres connection as the data source. 我正在Pentaho PUC中创建一个仪表板,该仪表板使用postgres连接作为数据源。 Most of the time this causes the postgres to say
在大多数情况下,这会导致postgres说
Too many clients already in Postgres'
Postgres中已经有太多客户了
SHOW max_connections;
Query shows maximum connections of 200 查询显示最大连接数为200
I used this query select * from pg_stat_activity;
我用这个查询
select * from pg_stat_activity;
. 。 From that 90% of connections are from the Pentaho server to the database I use as the datasource in my new dashboard.
其中90%的连接是从Pentaho服务器到数据库的连接,我将其用作新仪表板中的数据源。
waiting
is f
and state
is idle
in most of the connections. 在大多数连接中,
f
waiting
, state
为idle
。 This looks like Pentaho is creating too many connections. 看来Pentaho创建了太多的连接。 How can I limit or Control it?
如何限制或控制它? I have already tried increasing connection limit from default 100 to 200 from postgres side but still the issue is there.
我已经尝试从postgres方面将连接限制从默认的100增加到200,但是仍然存在问题。
From the comments thread on the original question it seems you're using SQL over JDBC connections on your dashboard. 从原始问题的注释线程看来,您正在仪表板上使用基于JDBC连接的SQL。 This will create a different database connection for each query that needs to run and if they are somewhat slow you may reach the limit on the number of concurrent connections.
这将为每个需要运行的查询创建一个不同的数据库连接,如果它们运行缓慢,则可能会达到并发连接数限制。
Instead, you should set up a JNDI: on your datasource management window add a new connection and set up the correct credentials. 相反,您应该设置一个JNDI:在数据源管理窗口上添加一个新连接并设置正确的凭据。 Under advanced options set up a connection pool.
在高级选项下,设置连接池。 Give it a meaningful name.
给它起一个有意义的名字。 From that point on, you should refer to that name on your dashboard queries and use SQL over JNDI instead of SQL over JDBC.
从那时起,您应该在仪表板查询中引用该名称,并使用基于JNDI的SQL而不是基于JDBC的SQL。 This way each SQL query will get a connection from the connection pool and the DB only sees 1 connection at each time, despite running multiple queries.
这样,每个SQL查询都会从连接池中获得一个连接,尽管运行多个查询,但DB每次只能看到1个连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.