Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL statement timeout

Tags:

postgresql

PostgreSQL Version: 9.3

We have online system which gets transnational data (approximately 15000 records per day).

We have table partitioning on date & time and have a PostgreSQL function to load the incoming request into the table.

Sometimes we see the error message

ERROR: 57014: canceling statement due to statement timeout

The client sends the request again after some time if not successful and on second try it gets recorded successfully. It seems this has to be something with table locks but I am not sure.

like image 980
Jayadeep Avatar asked Nov 14 '18 07:11

Jayadeep


People also ask

What is statement timeout?

Stops any statement that takes over the specified number of milliseconds. The statement_timeout value is the maximum amount of time a query can run before Amazon Redshift terminates it. This time includes planning, queueing in workload management (WLM), and execution time.

What is idle in transaction in Postgres?

idle in transaction: This indicates the backend is in a transaction, but it is currently not doing anything and could be waiting for an input from the end user.

Where is PostgreSQL idle sessions?

If you want to see how many idle connections you have that have an open transaction, you could use: select * from pg_stat_activity where (state = 'idle in transaction') and xact_start is not null; This will provide a list of open connections that are in the idle state, that also have an open transaction.

What is Tcp_keepalives_idle?

tcp_keepalives_idle ( integer ) Specifies the amount of time with no network activity after which the operating system should send a TCP keepalive message to the client. If this value is specified without units, it is taken as seconds. A value of 0 (the default) selects the operating system's default.


1 Answers

Set log_lock_waits = on in postgresql.conf and see if you get log entries. That would tell you that a query is hanging for more than one second.

like image 112
Laurenz Albe Avatar answered Sep 18 '22 06:09

Laurenz Albe