How to change PostgreSQL Studio's inactivity timeout? - postgresql

I want to increase PostgreSQL's Studio login/session time out time. When I leave PostgreSQL Studio to idle just for some time, I get the following message:
You have been logged out due to inactivity. Please relogin or exit.
I am using PostgreSQL from BigSQL 5.0.3 package bundle. Actually, I am researching about compability of MS SQL Server and PostgreSQL queries.
As I am using Postgres now for learning purpose rather than security, I feel it annoying to login frequently.
How can I increase the login/session timeout inside PostgreSQL Studio?

Postgres itself doesn't have an idle connection timeout. This is coming from something else.

Unfortunately, the timeout value is hard-coded to 30 minutes in PostgreSQL Studio. You should only see that if you are not using Studio at all for 30 minutes. Its a pretty simple matter to move that property to the config file so it can be changed. We just need to write a patch.
The timeout is to prevent Studio from holding open idle connections to PostgreSQL. PostgreSQL Studio uses connection pooling to manage connections back to the database so if the browser connection goes away without logging out, we need a way to remove those connections.

Related

postgres query timeout issue while using connection pooling in JBoss

I am facing the below issue
ERROR: canceling statement due to user request
inconsistently after I enabled query timeout for xa datasource in my xxx-ds.xml. I have added the following in my ds xml file.
<query-timeout>180</query-timeout>
The query timeout is set for 180 seconds, which means any sql query
that takes more than 180 seconds will get cancelled from application
server side.
But the issue I am facing is inconsistent and the queries gets timed out now and then without taking exactly 180 seconds.
We are using connection pooling also.
While searching stackoverflow found this question, which discusses about the possible causes for this issue while using connection pooling.
The solution suggested there was to set statement_timeout setting in postgresql.conf file. But it is bit difficult for me to enable statement_timeout setting in my database environment as the DB server is shared by multiple applications.
I would like to have a solution to terminate timed out queries from client side effectively and consistently while using connection pooling. I am using
JBoss 4.2.2-GA
postgresql 9.2 (64 bit)
java 1.7
postgresql-9.2-1002.jdbc4.jar
It looks like the issue is with postgresql driver 9.2. When I upgraded to 9.3, issue is fixed.

SQL workbench This connection has been closed in few minutes

I use SQL workbench to connect postgresql. But I frequently get following error
This connection has been closed.
when ever I kept the window idle for 2-3 minutes.
I am not sure where to the change the settings. Please help me .
Version : Build 118.7
If the server is configured to disconnect idle connections, you can configure a statement that is sent to the database server in regular intervals.
This is done in the connection profile. Click on the "Connect scripts" button:
Connection dialog
Then enter a statement for "Statement to keep connection alive".
Connect scripts
In the "Idle time" you can configure how often the statement should be executed. "1m" means that it's run every minute unless you run statements manually (or do something in the DbExplorer)
This should prevent the server to disconnect your session.

not able to connect postgresql after 30 connections

I have 2 cloud servers of postgresql, 1st one is working fine but in second after 30 mins i am not able to connect from java application. When i connect from pgadmin it shows 30 to 40 connection and after killing those connection every thing runs smooth.
its
configuration:
postgresql/9.3
max_connections = 100
shared_buffers = 4GB
When same application is connect to other postgresql with same schema every thing works fine forever
Configuration:
postgresql/9.1
max_connections = 100
shared_buffers = 32MB
Can u please help me to understand or fix the issue
I work on a PostgreSQL 9.3 instance with hundreds of open connections. I concur to you that the open connections themselves shouldn't be a problem. Sine we don't have much information, what follows is a description of how to get started troubleshooting.
Check server logs for anything wrong. Maybe there is an issue on the OS level with initiating connections?
Try logging in with psql as the application user. Does the problem persist? If not, the problem is not with PostgreSQL. I would take a closer look at the Java code and see if something is happening there.
Note that psql and other libpq actions may not give you the full picture. Try connecting locally over a non-SSL connection while watching a packet capture. You can find (and look up) the SQLSTATE error of the connection in this case. This is because, for legacy and backwards compatibility reasons libpq does not pass the sqlstate up to the client app when connecting to the database.
My bet though is that this is not a postgresql issue. It may be an operating system issue. It may be a resource issue. It may be a client application issue.

How to set connection timeout value for pgAdmin?

I am using pgAdmin to connect remotely to my database as phpPgAdmin is a bit limited in its features. Only problem is if I leave the SQL window open without running a query for a few minutes, then it says I need to reconnect.
Is this a setting I need to change in my database to keep remote connections alive for longer or is it a pgAdmin setting?
It is client setting.
You need specify connect_timeout in your config file.
29.1. Database Connection Control Functions
29.14. The Connection Service File

Does database connection stay opened except for errors and explicit closure?

Assuming that no statements to close the connection are made before my script ends and no exception is encountered before closing the connection, does the database's connection stay open?
I'm connecting to the database programmatically via Python Psycopg2 and via Java JDBC4 driver.
Not entirely sure what you want exactly, but let's try:
You can see the connections that exist at any time with PGAdmin or this SQL command
SELECT * FROM pg_stat_activity;
It should be fairly simple to spot when - for your specific use case - the connection closes.
If an SQL query is running at the time you close a connection, I think it will run to completion, ie the backend serving it will remain alive, even if the connection is closed from the client side.