Ecto: tcp recv: closed (the connection was closed by the pool with PostgreSQL 11

Created on 8 Feb 2020  路  5Comments  路  Source: elixir-ecto/ecto

Precheck

  • Do not use the issues tracker for help or support requests (try Elixir Forum, Stack Overflow, IRC or mailing lists, etc).
  • For proposing a new feature, please start a discussion on elixir-ecto.
  • For bugs, do a quick search and make sure the bug has not yet been reported.
  • Finally, be nice and have fun!

Environment

  • Elixir version (elixir -v): 1.9.1
  • Database and version (PostgreSQL 9.4, MongoDB 3.2, etc.): PostgreSQL 11.5(AWS RDS)
  • Ecto version (mix deps): 3.3.1
  • Database adapter and version (mix deps): postgrex 0.15.3
  • Operating system: Debian

Current behavior

After I upgrade to postgresql 11, I got this error on one table, but sql queries against other tables are ok.

** (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)
    (ecto_sql) lib/ecto/adapters/sql.ex:629: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:181: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (naboo) lib/naboo/feeds/feeds.ex:689: anonymous fn/1 in Naboo.Feeds.views_list/1
    (naboo) lib/cache/redis_store.ex:117: Cache.RedisStore.fetch/3
    (naboo) lib/naboo/feeds/feeds.ex:634: Naboo.Feeds.push_view/2
    (naboo) lib/naboo/media/media.ex:852: Naboo.Media.create_view/3
2020-02-08 06:19:04.590 [info] {%DBConnection.ConnectionError{
   message: "tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)",
   severity: :error
 },

and it's bad to normal after I rollback to postgresql 10.

our timeout setting for repo is default.

config :naboo, Naboo.Repo,
  adapter: Ecto.Adapters.Postgres,
  types: Naboo.PostgresTypes,
  username: System.fetch_env!("DB_USERNAME"),
  password: System.fetch_env!("DB_PASSWORD"),
  database: System.fetch_env!("DB_NAME"),
  hostname: System.fetch_env!("DB_HOST"),
  pool_size: 50

Most helpful comment

Sorry, I've figured out it's db server side problem, thanks for your effort.

Would be great if you would include details of what the problem was. Your description sounds like the problem I'm encountering.

All 5 comments

Can you please provide a sample app that reproduces the error? Thank you!

Sorry, I've figured out it's db server side problem, thanks for your effort.

Sorry, I've figured out it's db server side problem, thanks for your effort.

Would be great if you would include details of what the problem was. Your description sounds like the problem I'm encountering.

@xdays Can you describe what the problem on the server side was or how you debugged this one?

Sorry guys, I can't remember how I fixed it from the db server side. This is a common error, you need pay attends to:

  1. ecto pool_size
  2. postgres server max_connections
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stavro picture stavro  路  4Comments

ericmj picture ericmj  路  3Comments

AndresOsinski picture AndresOsinski  路  5Comments

sntran picture sntran  路  4Comments

nathanjohnson320 picture nathanjohnson320  路  4Comments