Tenancy create schema concurrency errors on Tests

64) test Organization resource actions can create organization without slug (no validation currently) (.Accounts.OrganizationTest)
test//accounts/organization_test.exs:49
match (=) failed
code: assert {:ok, organization} = Accounts.create_organization(attrs, authorize?: false)
left: {:ok, organization}
right: {
:error,
%Ash.Error.Unknown{bread_crumbs: ["Error returned from: .Accounts.Organization.create"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 40P01 (deadlock_detected) deadlock detected\n\n hint: See server log for query details.\n\nProcess 13782 waits for ShareRowExclusiveLock on relation 16549 of database 16389; blocked by process 13793.\nProcess 13793 waits for ShareRowExclusiveLock on relation 16509 of database 16389; blocked by process 13787.\nProcess 13787 waits for RowExclusiveLock on relation 16549 of database 16389; blocked by process 13782.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: .Accounts.Organization.create"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
}
64) test Organization resource actions can create organization without slug (no validation currently) (.Accounts.OrganizationTest)
test//accounts/organization_test.exs:49
match (=) failed
code: assert {:ok, organization} = Accounts.create_organization(attrs, authorize?: false)
left: {:ok, organization}
right: {
:error,
%Ash.Error.Unknown{bread_crumbs: ["Error returned from: .Accounts.Organization.create"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 40P01 (deadlock_detected) deadlock detected\n\n hint: See server log for query details.\n\nProcess 13782 waits for ShareRowExclusiveLock on relation 16549 of database 16389; blocked by process 13793.\nProcess 13793 waits for ShareRowExclusiveLock on relation 16509 of database 16389; blocked by process 13787.\nProcess 13787 waits for RowExclusiveLock on relation 16549 of database 16389; blocked by process 13782.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: .Accounts.Organization.create"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
}
How I can solve this problem ?
1 Reply
barnabasj
barnabasj3mo ago
For the specific test for the tenant resource, you can run that one with async: false , for other tests it's recommended to create/seed two or so organizations and reuse them in the tests.

Did you find this page helpful?