Postgres Error `(Postgrex.Error) ERROR 57014 (query_canceled) canceling statement due to user request`

There are unique fields in the User table which can cause conflicts. So we introuduced the on_conflict: :nothing.

Repo.insert_all(
  User,
  [
    %{
         user_id:  user.id,
         wallet_source_id: source_id,
         number: "..." 
       },
      %{
         user_id:  user_2.id,
         wallet_source_id: source_2.id,
         number: "..." 
       }
  ],
returning: false,
on_conflict: :nothing
)

Subsequently, no unique constraint errors but we are seeing postgres throwing

** (Postgrex.Error) ERROR 57014 (query_canceled) canceling statement due to user request

Any insights to the possible root cause?

1 Like

We are experiencing the same query_canceled issue with liveview when a user jumps to another page before the query completed. This insight might be helpful, might be misleading, I have no idea :D.

It can also be caused by timeout of executing the query. See this link:

Cause

This error is returned by your PostgreSQL client himself which stops the query execution, that means the query took too much time and its timeout has been reached.

The problem could be solved by changing your datasource configuration.