Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout failing #41

Open
dant4z opened this issue Jul 29, 2015 · 5 comments
Open

timeout failing #41

dant4z opened this issue Jul 29, 2015 · 5 comments

Comments

@dant4z
Copy link

dant4z commented Jul 29, 2015

Hi, i have some trouble.

I have query that returns 789 rows:

SELECT "brand_id", "brand_name" FROM "brands" GROUP BY "brand_id", "brand_name" ORDER BY "brand_name" ASC;
Execution Time: 2.558 ms

But sometimes i have suspension this query and failing by timeout.
In postgres in pg_stat_activity i see:

=# select state, query, now() - query_start as duration from pg_stat_activity order by duration desc limit 1;
-[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------------
state | idle
query | SELECT "brand_id", "brand_name" FROM "brands" GROUP BY "brand_id", "brand_name" ORDER BY "brand_name" ASC
duration | 00:00:57.017424

According to http://www.postgresql.org/docs/9.4/static/monitoring-stats.html
query: "Text of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed."
state = idle: The backend is waiting for a new client command.

That means that query was executed and postgres is waiting for a new nginx command. Then timeout (1 minute) expires and nginx returns 500 with timeout.

config:
upstream database {
postgres_server xxxxxxxxxxx;
postgres_keepalive off;
}
..................
.................
server {
location = /query {
internal;
postgres_pass database;
postgres_connect_timeout 30s;
postgres_result_timeout 1m;
postgres_query $echo_request_body;
}
}

Also i have similarly query (returns 928 rows) that also sometimes suspending.
I noticed that hang queries that return many rows.

Please help me to understand, that's going on.
Thanks.

@agentzh
Copy link
Contributor

agentzh commented Jul 31, 2015

@dant4z What versions of ngx_postgres and libpq are you using? If you're not using the latest, please try upgrading first.

@agentzh
Copy link
Contributor

agentzh commented Jul 31, 2015

@dant4z Also you may want to look at this ticket: #12

@dant4z
Copy link
Author

dant4z commented Jul 31, 2015

I'm using libpq 9.4.4-1, and ngx_postgres 1.0rc6. Also i saw this problem at 1.0rc5.

I'm using latest openresty 1.7.10.2, that includes ngx_postgres 1.0rc6

@agentzh
Copy link
Contributor

agentzh commented Jul 31, 2015

@dant4z Will you try the patch for libpq in #12 ? Not sure if it is it. Still worth trying anyway.

@istr
Copy link

istr commented Feb 18, 2016

I have the same issue with openresty 1.9.7.3 (includes ngx_postgres-1.0rc7) and libpq-9.3.11.

Will try the mentioned patch, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants