oban-bg / oban

💎 Robust job processing in Elixir, backed by modern PostgreSQL and SQLite3
https://oban.pro
Apache License 2.0
3.31k stars 309 forks source link

cache lookup failed for type #345

Closed a-kinder closed 4 years ago

a-kinder commented 4 years ago

Environment

Current Behavior

     ** (Postgrex.Error) ERROR XX000 (internal_error) cache lookup failed for type 41787001
     code: assert %{success: 0, failure: 0, discard: 1} == Oban.drain_queue(queue: :data_purge)
     stacktrace:
       (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:593: Ecto.Adapters.SQL.raise_sql_call_error/1
       (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:526: Ecto.Adapters.SQL.execute/5
       (ecto 3.4.6) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
       (oban 2.1.0) lib/oban/query.ex:33: anonymous fn/5 in Oban.Query.fetch_available_jobs/4
       (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:875: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
       (db_connection 2.2.2) lib/db_connection.ex:1427: DBConnection.run_transaction/4
       (oban 2.1.0) lib/oban/queue/drainer.ex:44: Oban.Queue.Drainer.fetch_jobs/2
       (oban 2.1.0) lib/oban/queue/drainer.ex:27: Oban.Queue.Drainer.drain/2
       .../jobs/campaign_batch_test.exs:33: (test)

Expected Behavior

During tests, this error is observed intermittently when using Oban.drain_queue, both in synchronous and asynchronous tests. It seems to be some kind of race condition with the status enum, possibly due to the select and update in a single transaction in Oban.Query?

sorentwo commented 4 years ago

This is a low level PG error. Do you happen to be dropping tables or re-running migrations within your tests?

a-kinder commented 4 years ago

We do have a migration rollback test, and one test using drain_queue was running asynchronously, will close this issue assuming that will fix it. Thanks!