Postgresql cant change max_connections - database

Here I have an issue. At this moment, I am using postgresql 10. I cant change default value of the max_connections = 100. I have tried to edit config postgresql.conf, tried to do this with sql query ALTER SYSTEM SET max_connections TO 'num';. After any changes, I tried to restart postgresql sudo service postgresql restart. But SHOW max_connections sql query still outputs with: max_connections = 100.
How to change max_connections value???

Related

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

ERROR: right sibling's left-link doesn't match: block 19 links to 346956 instead of expected 346955 in index "pg_depend_reference_index"

I have a DB in postgres. The DB is big with total size over 4TB and over 500,000 tables and many indexes. The DB is over 4 yr old.
Recently, the Pgsql DB server was not starting up, so I did the following to get it started again:
/usr/pgsql-9.3/bin/pg_resetxlog -f /var/lib/pgsql/9.3/data
/usr/pgsql-9.3/bin/pg_ctl -D /var/lib/pgsql/9.3/data stop
/usr/pgsql-9.3/bin/pg_ctl -D /var/lib/pgsql/9.3/data start
/usr/pgsql-9.3/bin/pg_ctl -D /var/lib/pgsql/9.3/data stop
systemctl restart postgresql-9.3
Since then I am getting the following error whenever I try to create a new table in the DB:
mps_schools=> create table test_test(hello int);
ERROR: right sibling's left-link doesn't match: block 19 links to 346956 instead of expected 346955 in index "pg_depend_reference_index"
I have tried re-indexing the DB, but it doesnt work. What more can I do?
pg_resetxlog destroyed your database, which is something that can easily happen, which is why you don't call it just because you don't get the database started. It's something of a last ditch effort to get a corrupted database up.
What can you do?
Best solution: restore from a backup from before you ran pg_resetxlog.
Perform an offline backup of your database.
Then start the database in single user mode:
postgres --single -P -D /your/database/directory yourdbname
Then try to reindex pg_depend:
REINDEX TABLE pg_catalog.pg_depend;
Exit the single user session, restart the database, run pg_dumpall to dump the database (and hope that it works), create a new database cluster with initdb and import the dump.
Don't continue using the cluster where you ran pg_resetxlog.

what is the default value for write timeout in postgres and MSSQL database connections?

I am using different databases to run my application. Recently I increased net_write_timeout value in mysql database, As I faced some timeout errors due to that. These errors are not occurred in Postgres or Mssql database.
My question is what is the equivalent flag of net_write_timeout (Mysql) for Postgres and Mssql database.
For SQL Server there are a couple of timeouts but nothing that directly corresponds to the net_write_timeout - afaik...
The default connection timeout (time allowed to connect to an instance) is 15 seconds. The default execution timeout (time allowed to execute a query etc) is 600. Connection timeout is set on the connection string, execution timeout on the connection in code, or at the server level by sp_configure
Refs: https://msdn.microsoft.com/en-AU/library/ms189040.aspx
and http://www.connectionstrings.com/all-sql-server-connection-string-keywords/

zabbix server pushing data to database

Is it possible to set zabbix server for oftener pushing data to database? We found out in postgres log that zabbix server pushes data to database every 5 seconds. How to update this interval for more realtime monitoring ?
You can probably change CONFIG_HISTSYNCER_FREQUENCY in src/zabbix_server/server.c to a lower value. It is 5 seconds by default.

Postgresql too many clients error on linux server

when i try connect postgresql 9.0 server on linux i get too many clients connected already. I tried increasing max_connections from 100 to 200 and start the server it doest take the max connections. What should i change on the linux server
Eclipse LogCat
Caused by: org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
This is a bit of a FAQ and is discussed in Number of Database Connections on the PostgreSQL wiki.
The only way to increase max_connections and persist this value is modifying the postgresql.conf file, so first of all, check if the value has changed (after restarting the server):
show max_connections
If the value DID NOT change, there's something wrong with your procedure (file permissions maybe?). If the value DID change, you might try with a higher value (weird, but might depend on your application connection requirements, OR a connection leak).

Resources