Skip to content

Unhandled StaleEntryError #1027

@landongrindheim

Description

@landongrindheim

The develop branch had a StaleEntryError exception introduced recently. Tests pass, but the output below is observed.

The stack trace points to CodeCorps.Accounts.upload_github_photo_async/1. I hadn't seen until very recently. If this isn't an issue, please feel free to close this issue (and let me know how to resolve it on my end 😄 )

2017-10-08T19:08:53.717753Z [error] Task #PID<0.5247.0> started from #PID<0.5245.0> terminating
** (stop) exited in: GenServer.call(#PID<0.5246.0>, {:checkout, #Reference<0.3912897079.3947626497.211182>, true, 15000}, 5000)
    ** (EXIT) shutdown: "owner #PID<0.5245.0> exited with: shutdown"
    (db_connection) lib/db_connection/ownership/proxy.ex:32: DBConnection.Ownership.Proxy.checkout/2
    (db_connection) lib/db_connection.ex:920: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:742: DBConnection.run/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
    (ecto) lib/ecto/repo/schema.ex:136: Ecto.Repo.Schema.update!/4
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<6.37107395/0 in CodeCorps.Accounts.upload_github_photo_async/1>
    Args: []
2017-10-08T19:08:53.727984Z [error] Task #PID<0.5250.0> started from #PID<0.5245.0> terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.5250.0>.

When using ownership, you must manage connections in one
of the four ways:

* By explicitly checking out a connection
* By explicitly allowing a spawned process
* By running the pool in shared mode
* By using :caller option with allowed process

The first two options require every new process to explicitly
check a connection out or be allowed by calling checkout or
allow respectively.

The third option requires a {:shared, pid} mode to be set.
If using shared mode in tests, make sure your tests are not
async.

The fourth option requires [caller: pid] to be used when
checking out a connection from the pool. The caller process
should already be allowed on a connection.

If you are reading this error, it means you have not done one
of the steps above or that the owner process has crashed.

    (db_connection) lib/db_connection.ex:926: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:742: DBConnection.run/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
    (ecto) lib/ecto/repo/schema.ex:136: Ecto.Repo.Schema.update!/4
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<6.37107395/0 in CodeCorps.Accounts.upload_github_photo_async/1>
    Args: []
2017-10-08T19:08:53.728153Z [error] Task #PID<0.5251.0> started from #PID<0.5245.0> terminating
** (Ecto.StaleEntryError) attempted to update a stale struct:

%CodeCorps.User{id: 552522, twitter: nil, email: "original@email.com", categories: #Ecto.Association.NotLoaded<association :categories is not loaded>, sign_up_context: "default", first_name: "First2491", github_app_installations: #Ecto.Association.NotLoaded<association :github_app_installations is not loaded>, user_roles: #Ecto.Association.NotLoaded<association :user_roles is not loaded>, github_app_installation: #Ecto.Association.NotLoaded<association :github_app_installation is not loaded>, encrypted_password: nil, password_confirmation: nil, stripe_platform_customer: #Ecto.Association.NotLoaded<association :stripe_platform_customer is not loaded>, website: nil, github_avatar_url: "https://github.com/images/error/octocat_happy.gif", username: "user3796", inserted_at: #DateTime<2017-10-08 19:08:53Z>, github_username: "octocat", last_name: nil, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, updated_at: #DateTime<2017-10-08 19:08:53Z>, user_skills: #Ecto.Association.NotLoaded<association :user_skills is not loaded>, github_id: 1, password: nil, state_transition: nil, github_email: nil, admin: nil, roles: #Ecto.Association.NotLoaded<association :roles is not loaded>, state: "signed_up", default_color: nil, github_auth_token: "foo_auth_token", biography: nil, skills: #Ecto.Association.NotLoaded<association :skills is not loaded>, stripe_connect_subscriptions: #Ecto.Association.NotLoaded<association :stripe_connect_subscriptions is not loaded>, user_categories: #Ecto.Association.NotLoaded<association :user_categories is not loaded>, cloudinary_public_id: nil, project_users: #Ecto.Association.NotLoaded<association :project_users is not loaded>, type: "user", stripe_connect_customers: #Ecto.Association.NotLoaded<association :stripe_connect_customers is not loaded>, slugged_route: #Ecto.Association.NotLoaded<association :slugged_route is not loaded>, stripe_platform_card: #Ecto.Association.NotLoaded<association :stripe_platform_card is not loaded>}

    (ecto) lib/ecto/repo/schema.ex:549: Ecto.Repo.Schema.apply/4
    (ecto) lib/ecto/repo/schema.ex:289: anonymous fn/14 in Ecto.Repo.Schema.do_update/4
    (ecto) lib/ecto/repo/schema.ex:768: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
    (ecto) lib/ecto/adapters/sql.ex:576: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
    (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
    (db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
    (ecto) lib/ecto/repo/schema.ex:136: Ecto.Repo.Schema.update!/4
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<6.37107395/0 in CodeCorps.Accounts.upload_github_photo_async/1>
    Args: []
2017-10-08T19:08:53.728369Z [error] Task #PID<0.5252.0> started from #PID<0.5245.0> terminating
** (Ecto.StaleEntryError) attempted to update a stale struct:

%CodeCorps.User{id: 552522, twitter: nil, email: "original@email.com", categories: #Ecto.Association.NotLoaded<association :categories is not loaded>, sign_up_context: "default", first_name: "First2491", github_app_installations: #Ecto.Association.NotLoaded<association :github_app_installations is not loaded>, user_roles: #Ecto.Association.NotLoaded<association :user_roles is not loaded>, github_app_installation: #Ecto.Association.NotLoaded<association :github_app_installation is not loaded>, encrypted_password: nil, password_confirmation: nil, stripe_platform_customer: #Ecto.Association.NotLoaded<association :stripe_platform_customer is not loaded>, website: nil, github_avatar_url: "https://github.com/images/error/octocat_happy.gif", username: "user3796", inserted_at: #DateTime<2017-10-08 19:08:53Z>, github_username: "octocat", last_name: nil, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, updated_at: #DateTime<2017-10-08 19:08:53Z>, user_skills: #Ecto.Association.NotLoaded<association :user_skills is not loaded>, github_id: 1, password: nil, state_transition: nil, github_email: nil, admin: nil, roles: #Ecto.Association.NotLoaded<association :roles is not loaded>, state: "signed_up", default_color: nil, github_auth_token: "foo_auth_token", biography: nil, skills: #Ecto.Association.NotLoaded<association :skills is not loaded>, stripe_connect_subscriptions: #Ecto.Association.NotLoaded<association :stripe_connect_subscriptions is not loaded>, user_categories: #Ecto.Association.NotLoaded<association :user_categories is not loaded>, cloudinary_public_id: nil, project_users: #Ecto.Association.NotLoaded<association :project_users is not loaded>, type: "user", stripe_connect_customers: #Ecto.Association.NotLoaded<association :stripe_connect_customers is not loaded>, slugged_route: #Ecto.Association.NotLoaded<association :slugged_route is not loaded>, stripe_platform_card: #Ecto.Association.NotLoaded<association :stripe_platform_card is not loaded>}

    (ecto) lib/ecto/repo/schema.ex:549: Ecto.Repo.Schema.apply/4
    (ecto) lib/ecto/repo/schema.ex:289: anonymous fn/14 in Ecto.Repo.Schema.do_update/4
    (ecto) lib/ecto/repo/schema.ex:768: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
    (ecto) lib/ecto/adapters/sql.ex:576: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
    (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
    (db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
    (ecto) lib/ecto/repo/schema.ex:136: Ecto.Repo.Schema.update!/4
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<6.37107395/0 in CodeCorps.Accounts.upload_github_photo_async/1>
    Args: []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions