findmypast-oss / mssqlex

Microsoft SQL Server Adapter for Elixir
Apache License 2.0
42 stars 22 forks source link

Random (Mssqlex.Error) connection_closed #23

Open pcharbon70 opened 5 years ago

pcharbon70 commented 5 years ago

We are randomly getting some connection_closed as an Mssqlex.Error when doing any insertion into the database. Whether it is a simple Repo.insert or an Ecto.multi in a transaction this seems to happen randomly but on a very noticeable frequency. From the error message (see below) it seems that this is coming from the Db_Connection pool.

Error example

[error] #PID<0.453.0> running CmiserverWeb.Endpoint (cowboy_protocol) terminated Server: localhost:4000 (http) Request: POST /api/v1/auth/checkout/submitorder ** (exit) an exception was raised: ** (Mssqlex.Error) connection_closed (db_connection) lib/db_connection.ex:802: DBConnection.transaction/3 (ecto) lib/ecto/repo/queryable.ex:21: Ecto.Repo.Queryable.transaction/4

Context

All the querying seems to work fine even on long queries and does not seem to be affected at all by these timeouts. We tried so far to increase both the the :pool_size and the :timeout on the Ecto.Repo configuration but that did not improve or seem to have any effect at all. I can't figure out why the queries would not timeout but all insertions do.

Our Environment

Any suggestion at where to look next while trying to figure this out would also be appreciated.

Thank you