Skip to content

Instantly share code, notes, and snippets.

@tony612
Last active April 21, 2016 14:13
Show Gist options
  • Select an option

  • Save tony612/d8c713cef3c409d3a5b2ff38927d7b64 to your computer and use it in GitHub Desktop.

Select an option

Save tony612/d8c713cef3c409d3a5b2ff38927d7b64 to your computer and use it in GitHub Desktop.
ecto deadlock
....
1) test get latest timestamp of user for a channel (Exchat.UserReadMessageRepoTest)
test/models/user_read_message_repo_test.exs:6
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 45728 waits for ShareLock on transaction 7900; blocked by process 45727.
Process 45727 waits for ShareLock on transaction 7898; blocked by process 45728.
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/user_read_message_repo_test.exs:8
........
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 45727 waits for ShareLock on transaction 7901; blocked by process 45725.
Process 45725 waits for ShareLock on transaction 7900; blocked by process 45727.
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
.......
3) test create_channel_user create channel_user and user_read_message (Exchat.ChannelUserServiceTest)
test/services/channel_user_service_test.exs:14
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 45733 waits for ShareLock on transaction 7913; blocked by process 45728.
Process 45728 waits for ShareLock on transaction 7916; blocked by process 45733.
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/services/channel_user_service_test.exs:16
.....................
Finished in 3.8 seconds (0.5s on load, 3.2s on tests)
43 tests, 3 failures
Randomized with seed 746463
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment