Thingsboard Community : multiple idle postgres connections - database

I noticed that one tb-core is using 16 db connections on my postgres db, why ? There is 15 idle connections and 1 active.
Postgres connections from TB
I have this for my current tb installation but also for a new one with latest tb version.
Thanks

Related

SSAS - Data Source: Maximum Number of Connections not working

I was playing with the Option "Maximum Number of Connections" within a Microsoft SSAS Multidimensional OLAP Solution. According to following article, SSAS will open more Connection to the Database and will process several Partitions.
http://henkvandervalk.com/how-to-process-a-ssas-molap-cube-as-fast-as-possible-part-2
When I change the value (16, 20 etc.) and monitor the connection in the activity monitor, I always see that SSAS only open 10 Connection at the same time. Is this option in a relation with other options ? When I change it to 4, then only 4 partitions will be process in parallel.
Thanks for any advice and hints.
My SSAS Options:
- ThreadPool \ Process \ MaxThreads: 320
- ThreadPool \ Query \ MaxThreads: 64
My Server:
- 32 Cores
- 512 GB RAM
look at the data source connection to the underlying database. The default number of connections there is 10.

Connection drop from postgresql on azure virtual machine

I am a bit new to postgresql db. I have done a setup over Azure Cloud for my PostgreSQL DB.
It's Ubuntu 18.04 LTS (4vCPU, 8GB RAM) machine with PostgreSQL 9.6 version.
The problem that occurs is when the connection to the PostgreSQL DB stays idle for some time let's say 2 to 10 minutes then the connection to the db does not respond such that it doesn't fulfill the request and keep processing the query.
Same goes with my JAVA Spring-boot Application. The connection doesn't respond and the query keep processing.
This happens randomly such that the timing is not traceable sometimes it happens in 2 minutes, sometimes in 10 minutes & sometimes don't.
I have tried with PostgreSQL Configuration file parameters. I have tried:
tcp_keepalive_idle, tcp_keepalive_interval, tcp_keepalive_count.
Also statement_timeout & session_timeout parameters but it doesn't change anyway.
Any suggestion or help would be appreciable.
Thank You
If you are setting up PostgreSQL DB connection on Azure VM you have to be aware that there are Unbound and Outbound connections timeouts . According to
https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-outbound-connections#idletimeout ,Outbound connections have a 4-minute idle timeout. This timeout is not adjustable. For inbound timeou there is an option to change in on Azure Portal.
We run into similar issue and were able to resolve it on client side. We changed Spring-boot default Hikari configuration as follow:
hikari:
connection-timeout: 20000
validation-timeout: 20000
idle-timeout: 30000
max-lifetime: 40000
minimum-idle: 1
maximum-pool-size: 3
connection-test-query: SELECT 1
connection-init-sql: SELECT 1

MS SQL server failover

We have a spring java application that connects to a MS SQL server cluster of 2 nodes (2016 SP2 standard version).
We are testing failover: if a node fails, the application needs 90 seconds before reconnecting to the other node, that will be too much for production.
After reading and reading again the HickaryCP documentation for java, I tried to test this scenario with datagrip: I run a long query (insert a line in a table every 500 ms during 10 minutes) and I get the same issue: the database was unavailable for 90 seconds after 1 node failure.
Maybe the issue is cluster side and not application side...
Is there any SQL server cluster configuration that prevent us to reconnect before 90 seconds?
How can the connection be back before these 90 seconds? is there any caching or default configuration that we should update?
Thanks a lot for your help
EDIT
The test was wrong, I updated in comments the issue I am getting:
it reconnects as soon as the 1st node is back. The issue is after a second failover: no connection can be established then (I wait for the 2 nodes synchronization before the 2nd failover)

Understanding multiple databases in Heroku

I recently installed the heroku dev database. Then when I type into the command line heroku pg:info I get THREE databases.
=== SHARED_DATABASE (DATABASE_URL)
Data Size 808k
=== HEROKU_POSTGRESQL_BRONZE
Plan Dev
Status available
Connections 1
PG Version 9.1.3
Created 2012-05-14 17:47 UTC
Tables 0
Conn Info "host=XXXXXX.compute-1.amazonaws.com
port=5432 dbname=resourceXXXXX
user=abcXXXXX sslmode=require
password=XXXXXXXXX"
=== HEROKU_POSTGRESQL_CHARCOAL
Plan Dev
Status available
Connections 1
PG Version 9.1.3
Created 2012-05-13 19:08 UTC
Tables 0
Conn Info "host=XXXXXXX.compute-1.amazonaws.com
port=5432 dbname=resourceXXXXX
user=YYYYYY sslmode=require
password=XXXXXXXXXXXXXXXX"
=== HEROKU_POSTGRESQL_GREEN
Plan Dev
Status available
Connections 1
PG Version 9.1.3
Created 2012-05-13 19:06 UTC
Tables 0
Conn Info "host=XXXXXXXXXXXX.compute-1.amazonaws.com
port=5432 dbname=resourceXXXXXX
user=XXXXXXXXXX sslmode=require
password=XXXXXXXXXXXXXX"
The host, resource, user, and password are different for each.
Why are there three? What's the difference between them?
With the dev plan similar to the production plan you are able to add multiple databases. Each of these is a unique database and you can connect to each of them individually.
If you wished to remove a database if you did not intend to add three you could:
heroku addons:remove HEROKU_POSTGRESQL_GREEN
To promote one of those to your primary database you may:
heroku pg:promote HEROKU_POSTGRESQL_GREEN
You may also connect to each of them individually:
heroku pg:psql HEROKU_POSTGRESQL_RED
If you install the add-on multiple times it creates multiple entries. I deleted the app and readded the addon and now there is only one entry. I guess previously, I inadvertently added the addon multiple times.

using JDBC Connection Pool with SQL Azure Database gives "Error in allocating a connection"

I have a Java EE web application deployed on glassfish 3.1.1 which I want to host on Windows Azure.
The application uses hibernate as jpa.
I defined a JDBC Connection Pool for the Azure database.
(basically, these are the defaults)
Initial and Minimum Pool Size: 8 Connections
Maximum Pool Size: 32 Connections
Pool Resize Quantity: 2 Connections
Idle Timeout: 300 Secconds
Max Wait Time: 60000 Milliseconds
Additional Properties:
User: user#serverName
ServerName: serverName.database.windows.net
Password: myPass
databaseName: mydatabase
If i ping it from the glassfish interface it works, so the properties I provide are ok.
Setting the new jdbc connection pool (the one for azure) resulted in the tables being created on the sql azure database (i have "hibernate.hbm2ddl.auto" set to update) - so there isn't a problem with the database connection/parameters.
If the application uses the database immediately after the server started, all goes well (it can retrieve/store data)
When the application tries to use the database after being idle for a while, I get this:
link to exception
If I flush the connection (from glassfish admin) it starts to work again, until it goes idle for a period of time.
So basically, as long as it executes database operations all works well, but if there are no database operations for a while, the next db operation will result in that exception.
I've google'd this and it seems to have something to do with the azure database server closing the idle connection, but I couldn't find a solution for the problem.
I never had this problem when using PostgreSql
One possible reason cause this problem: SQL Azure closes idle connections after 5 minutes. To work around this issue, you have to close the connection, and create a new connection. In general, it is recommended to close idle connections even when connecting to other databases. This helps to reduce system resource usage.

Resources