简体   繁体   English

AWS 上的 Postgres 11.8 在 15 分钟后失去连接/终止查询,没有通知或错误

[英]Postgres 11.8 on AWS Losing Connection/Terminating Query After 15 Minutes with No Notification or Error

I am running into an issue where multiple different clients apps (DataGrip, DBeaver, Looker) have their queries cancelled after exactly 15 minutes, but no termination message or connection error is ever sent to the app.我遇到了一个问题,即多个不同的客户端应用程序(DataGrip、DBeaver、Looker)在 15 分钟后取消了他们的查询,但没有向应用程序发送终止消息或连接错误。 As far as the app is concerned, the query is still running even though it has been terminated in Postgres.就应用程序而言,即使查询已在 Postgres 中终止,它仍在运行。

For example, if I run the following query, according to the client app it just runs forever.例如,如果我运行以下查询,根据客户端应用程序,它会永远运行。 If I check pg_stat_activity, it shows the query no longer running after 15 minutes.如果我检查 pg_stat_activity,它会显示查询在 15 分钟后不再运行。

SELECT pg_sleep(16 * 60);

Does anyone know of a Postgres or AWS setting that would cause this?有谁知道会导致这种情况的 Postgres 或 AWS 设置? I've checked the configuration and couldn't find any settings set to a value of 15 minutes (or 900 seconds).我检查了配置,但找不到任何设置为 15 分钟(或 900 秒)值的设置。

There is probably a ill-configured firewall that closes your session.可能有一个配置不当的防火墙会关闭您的会话。

Assuming that the clients you are mentioning use libpq to connect to PostgreSQL, include this in the connection string:假设您提到的客户端使用libpq连接到 PostgreSQL,请将其包含在连接字符串中:

keepalives_idle=300

See the documentation for details.有关详细信息,请参阅文档

You could of course also configure the TCP stack on your operating system to use that value, so the problem will never surface again.您当然也可以在操作系统上配置 TCP 堆栈以使用该值,这样问题就不会再次出现。

Your DB log might be able to tell you what happened.您的数据库日志可能会告诉您发生了什么。

In addition, check your statement_timeout setting.此外,请检查您的statement_timeout设置。 The units are milliseconds so you should be looking for 900000 , not 900 .单位是毫秒,所以你应该寻找900000 ,而不是900

If it's not that, there exist firewalls that kill idle connections.如果不是这样,则存在杀死空闲连接的防火墙。 Setting tcp_keepalives_idle could help avoid those types of problems.设置tcp_keepalives_idle可以帮助避免这些类型的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Postgres 连接在闲置 15 分钟后断开 - Postgres Connection drops after 15 mins of idleness 使用 Navicat Premium 连接到 Postgres 15 后无法打开连接 - Cannot open connection after connecting to Postgres 15 using Navicat Premium 如何使用postgres按小时或15分钟分组 - How to group by hourly or 15 minutes using postgres 在Windows中,停止postgres服务会导致节点崩溃,并显示“错误:由于管理员命令而终止连接” - In windows, stopping postgres service causes node to crash with “error : terminating connection due to administrator command” Heroku Postgres 数据库随机崩溃,“错误:由于管理员命令而终止连接” - Heroku Postgres database randomly crashing, “error: terminating connection due to administrator command” Unicorn在heroku上一直失去与postgres数据库的连接 - Unicorn keeps losing connection to postgres database on heroku 使用 Python 连接到 AWS Postgres 数据库:连接被拒绝错误 - Connecting to AWS Postgres database using Python: connection refused error AWS Lambda 上的节点、Postgres 出现“连接意外终止”错误 - "connection terminated unexpectedly" error with Node, Postgres on AWS Lambda 由于另一个服务器进程崩溃而终止连接-Postgres - Terminating connection because of crash of another server process -Postgres 在 Pl/pgSQL 中使用 FOR 循环时,它在 Postgres 11.8 中不起作用 - FOR-loop does NOT work in Postgres 11.8 when using it in Pl/pgSQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM