Repo return the result before commit transaction

My function:

  |> Client.changeset(%{user_id: user_id, region_id: region_id})
  |> Repo.insert

return {:ok, client}
Then I send the task to the external system, it returns an error: RecordNotFound: Couldn’t find Client with id

Can I request a response to be returned only after the transaction is completed in the database.

My Database - postgresql

Thank you and I apologize for using google translate

Unless you are in a multi, or in a transaction, everything should be commited at the moment that insert returns.

So can you provide a sample project that reproduces your problem?

Yes. It turned out that the transaction was at the controller level

1 Like