ClientRead statement_timeout
See original GitHub issueI have been observing a strange behaviour where PostgreSQL backends created by node-postgres are hanging in ClientRead state.
cinema_data_task_executor=> SHOW statement_timeout;
statement_timeout
-------------------
10s
(1 row)
cinema_data_task_executor=> SELECT
cinema_data_task_executor-> psa1.backend_start,
cinema_data_task_executor-> psa1.pid,
cinema_data_task_executor-> now() - psa1.query_start duration,
cinema_data_task_executor-> psa1.query,
cinema_data_task_executor-> psa1.state,
cinema_data_task_executor-> psa1.application_name,
cinema_data_task_executor-> psa1.wait_event_type,
cinema_data_task_executor-> psa1.wait_event,
cinema_data_task_executor-> psa1.usename
cinema_data_task_executor-> FROM pg_stat_activity psa1
cinema_data_task_executor-> WHERE
cinema_data_task_executor-> psa1.pid = 29342 AND
cinema_data_task_executor-> psa1.state = 'active'
cinema_data_task_executor-> ORDER BY psa1.query_start ASC;
backend_start | pid | duration | query | state | application_name | wait_event_type | wait_event | usename
-------------------------------+-------+-----------------+------------------------------------------------------------------------------------------------------+--------+--------------------------+-----------------+------------+---------------------------
2019-08-20 20:25:00.282386+00 | 29342 | 00:08:02.920093 | UPDATE event_seating_lookup SET last_seen_at = now() WHERE id = $1 AND ended_at IS NULL RETURNING id | active | do-event-seating-lookups | Client | ClientRead | cinema_data_task_executor
(1 row)
In the above example you can see a backend with statement_timeout
set to 10 seconds. Meanwhile, the particular query has been running for 8 minutes. From Node.js perspective, the program is just hanging after sending the query.
There appears to be a case where node-postgres is stuck in ClientRead state.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:18 (14 by maintainers)
Top Results From Across the Web
15: 20.11. Client Connection Defaults - PostgreSQL
The timeout is measured from the time a command arrives at the server until it is completed by the server. If multiple SQL...
Read more >Client:ClientRead - Amazon Aurora - AWS Documentation
The Client:ClientRead event occurs when Aurora PostgreSQL is waiting to receive data from the client.
Read more >PostgreSQL lessons we learned the hard way - Medium
Client |ClientRead |idle in transaction| select * from ... can do it in the SQL code of the migration itself with a local...
Read more >Postgres queries running longer than statement_timeout
... wait_event is ClientRead ) and this means they are governed by a different timeout (although the documentation is ambiguous about this).
Read more >Connection handling best practice with PostgreSQL
To help with this, Postgres has a nice feature of a statement_timeout. A statement timeout will automatically end queries that run longer than ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
hmmm yeah if the native driver doesn’t exhibit the behavior it’s almost certainly something we can solve on our end in the JS driver. I’m out of the country for a couple more days but as soon as I get back I’ll take a look at this in detail and see if I can get a tight reproducible case I can work on.
On Sat, Nov 9, 2019 at 9:20 PM Murukesh Sadasivan notifications@github.com wrote:
@brianc For what it is worth, I just discovered that switching to
require('pg').native
makes the issue go away.