PostgreSQL connections are not released after QR/reconnect failures

未关闭
#112 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
go, postgresql
领域
backend, databases

调研方向

首先,在监控 Evolution GO 容器中的 PostgreSQL 连接时,复现 QR、重新连接和会话初始化失败流程。检查这些流程涉及的数据库路径,以及 evolution-client.ts 和 functions/evolution-send-text/index.ts,以调查报告中的发送失败问题;当失败尝试不再累积空闲连接或耗尽 max_connections 时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug
Welcome!
  • Yes, I have searched for similar issues on GitHub and found none.
What did you do?

I am running Evolution GO in Docker with PostgreSQL 15 on Linux.

Environment summary:

  • evolution-go: 0.7.2
  • Docker image: evoapicloud/evolution-go:0.7.2
  • PostgreSQL 15
  • standalone Docker Compose deployment

I have 2 WhatsApp instances.

After QR generation / reconnect attempts, the application started failing to reconnect properly. During investigation, I checked PostgreSQL activity and noticed a large number of idle connections coming from the Evolution GO container, especially against the auth database.

At one point, PostgreSQL reached the connection limit and Evolution GO started failing on QR and send flows.

Restarting only the evolution-go container released those connections and the QR flow started working again.

This looks like database connections may not be properly released after failed initialization or reconnect attempts.

What did you expect?

I expected Evolution GO to reuse or release PostgreSQL connections correctly during QR generation, reconnect attempts, and failed session initialization.

Even if an instance fails to reconnect, the application should not keep accumulating idle database connections until PostgreSQL reaches max_connections.

What did you observe instead of what you expected?

Instead, PostgreSQL connections kept accumulating as idle connections from the Evolution GO container.

After enough reconnect / QR attempts, PostgreSQL started returning connection limit errors and Evolution GO stopped working correctly.

Observed effects:

  • QR code endpoint failed
  • send flows failed
  • instance/session state became inconsistent
  • application logs later showed "no active session found"

The issue was temporarily resolved by restarting only the evolution-go container, which immediately reduced the number of open PostgreSQL connections.

Screenshots/Videos

I can provide:

  • screenshots of the disconnected instance state
  • QR refresh failure
  • logs showing "no active session found"
  • PostgreSQL connection counts before and after restarting the container
Which version are you using?

0.7.2
Docker image: evoapicloud/evolution-go:0.7.2
PostgreSQL 15

What is your environment?

Linux

If applicable, paste the log output

Initial related error:
failed to upgrade database: failed to check if version table is up to date: pq: sorry, too many clients already

Later application error:
Erro ao enviar texto: Error: no active session found
at request (.../functions/_shared/evolution-client.ts:404:13)
at async Server. (.../functions/evolution-send-text/index.ts:50:20)

Database observation:

  • max_connections: 100
  • idle connections reached: 99 for the auth database
  • after restarting only the evolution-go container, connections dropped back to normal
Additional Notes

This report is based on repeated behavior in production.

I cannot fully confirm yet whether this is an upstream bug or an environment-specific issue, but the behavior strongly suggests a connection leak or missing connection cleanup during failed QR/reconnect/session initialization flows.

Also, I noticed that one status endpoint appeared stale while another status endpoint reflected the live state correctly. If needed, I can open a separate issue specifically for the status inconsistency, since it may be unrelated to the PostgreSQL connection accumulation problem.

主要语言
Go
星标
971
派生
519
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

evolution-foundation/evolution-go 的其他 Issue

查看 evolution-foundation/evolution-go 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。