Skip to content

Instantly share code, notes, and snippets.

@tony612
Created April 21, 2016 14:13
Show Gist options
  • Save tony612/dce4541d2e7ee6a36372bb801fe23c29 to your computer and use it in GitHub Desktop.
Save tony612/dce4541d2e7ee6a36372bb801fe23c29 to your computer and use it in GitHub Desktop.
ecto deadlock
...................
1) test the result of messages_before is ordered by desc inserted_at (Exchat.ChannelRepoTest)
test/models/channel_repo_test.exs:29
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 46231 waits for ShareLock on transaction 8105; blocked by process 46227.
Process 46227 waits for ShareLock on transaction 8107; blocked by process 46231.
stacktrace:
(ecto) lib/ecto/adapters/sql.ex:405: Ecto.Adapters.SQL.struct/6
(ecto) lib/ecto/repo/schema.ex:373: Ecto.Repo.Schema.apply/5
(ecto) lib/ecto/repo/schema.ex:179: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4
(ecto) lib/ecto/repo/schema.ex:581: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
(ecto) lib/ecto/adapters/sql.ex:450: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
(db_connection) lib/db_connection.ex:1079: DBConnection.transaction_run/4
(db_connection) lib/db_connection.ex:1009: DBConnection.run_begin/3
(db_connection) lib/db_connection.ex:766: DBConnection.transaction/3
(ecto) lib/ecto/repo/schema.ex:112: Ecto.Repo.Schema.insert!/4
test/models/channel_repo_test.exs:31
2) test creates and renders resource with ChannelUser and UserReadMessage when data is valid (Exchat.ChannelControllerTest)
test/controllers/channel_controller_test.exs:33
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 46227 waits for ShareLock on transaction 8106; blocked by process 46234.
Process 46234 waits for ShareLock on transaction 8105; blocked by process 46227.
stacktrace:
(ecto) lib/ecto/adapters/sql.ex:405: Ecto.Adapters.SQL.struct/6
(ecto) lib/ecto/repo/schema.ex:373: Ecto.Repo.Schema.apply/5
(ecto) lib/ecto/repo/schema.ex:179: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4
(ecto) lib/ecto/repo/schema.ex:581: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
(db_connection) lib/db_connection.ex:1164: DBConnection.transaction_nested/2
(db_connection) lib/db_connection.ex:1030: DBConnection.transaction_meter/3
(db_connection) lib/db_connection.ex:766: DBConnection.transaction/3
(exchat) web/services/channel_user_service.ex:9: anonymous fn/2 in Exchat.ChannelUserService.insert_channel/2
(ecto) lib/ecto/adapters/sql.ex:450: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
(db_connection) lib/db_connection.ex:1079: DBConnection.transaction_run/4
(db_connection) lib/db_connection.ex:1009: DBConnection.run_begin/3
(db_connection) lib/db_connection.ex:766: DBConnection.transaction/3
(exchat) web/controllers/channel_controller.ex:15: Exchat.ChannelController.create/2
(exchat) web/controllers/channel_controller.ex:1: Exchat.ChannelController.action/2
(exchat) web/controllers/channel_controller.ex:1: Exchat.ChannelController.phoenix_controller_pipeline/2
(exchat) lib/phoenix/router.ex:261: Exchat.Router.dispatch/2
(exchat) web/router.ex:1: Exchat.Router.do_call/2
(exchat) lib/exchat/endpoint.ex:1: Exchat.Endpoint.phoenix_pipeline/1
(exchat) lib/phoenix/endpoint/render_errors.ex:34: Exchat.Endpoint.call/2
(phoenix) lib/phoenix/test/conn_test.ex:194: Phoenix.ConnTest.dispatch/5
......................
Finished in 2.7 seconds (0.5s on load, 2.2s on tests)
43 tests, 2 failures
Randomized with seed 898749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment