oban-bg / oban

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

Crash when upgrading to Ecto 3.12 #1137

Closed guess closed 1 month ago

guess commented 1 month ago

Environment

Current Behavior

Since upgrading to Ecto 3.12.1, I have been getting this crash, and I'm not sure if this is an Ecto issue or if Oban needs to change anything related to the changes made from Ecto 3.12, so just wanted to bring to your attention.

[error] GenServer {Oban.Registry, {Oban, Oban.Stager}} terminating
** (FunctionClauseError) no function clause matching in Ecto.Adapters.Postgres.Connection.distinct/3
    (ecto_sql 3.11.3) lib/ecto/adapters/postgres/connection.ex:482: Ecto.Adapters.Postgres.Connection.distinct(%Ecto.Query.ByExpr{expr: true, file: "/app/deps/oban/lib/oban/engines/basic.ex", line: 178, params: nil, subqueries: []}, {{[[34, "public", 34], 46, [34, "oban_jobs", 34]], [111 | "0"], Oban.Job}, []}, #Ecto.Query<from j0 in Oban.Job, where: j0.state == "available", where: not is_nil(j0.queue), distinct: true, select: j0.queue>)
    (ecto_sql 3.11.3) lib/ecto/adapters/postgres/connection.ex:162: Ecto.Adapters.Postgres.Connection.all/2
    (ecto_sql 3.11.3) lib/ecto/adapters/postgres.ex:132: Ecto.Adapters.Postgres.prepare/2
    (ecto 3.12.1) lib/ecto/query/planner.ex:202: Ecto.Query.Planner.query_without_cache/4
    (ecto 3.12.1) lib/ecto/query/planner.ex:170: Ecto.Query.Planner.query_prepare/6
    (ecto 3.12.1) lib/ecto/query/planner.ex:143: Ecto.Query.Planner.query_with_cache/8
    (ecto 3.12.1) lib/ecto/repo/queryable.ex:214: Ecto.Repo.Queryable.execute/4
    (ecto 3.12.1) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    (oban 2.18.0) lib/oban/engines/basic.ex:180: Oban.Engines.Basic.check_available/1
    (oban 2.18.0) lib/oban/engine.ex:264: anonymous fn/2 in Oban.Engine.check_available/1
    (oban 2.18.0) lib/oban/engine.ex:339: anonymous fn/3 in Oban.Engine.with_span/4
    (telemetry 1.2.1) /app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (oban 2.18.0) lib/oban/stager.ex:88: Oban.Stager.notify_queues/1
    (oban 2.18.0) lib/oban/stager.ex:73: anonymous fn/1 in Oban.Stager.stage_and_notify/2
    (ecto_sql 3.11.3) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.7.0) lib/db_connection.ex:1756: DBConnection.run_transaction/4
    (oban 2.18.0) lib/oban/stager.ex:70: Oban.Stager.stage_and_notify/2
    (oban 2.18.0) lib/oban/stager.ex:57: anonymous fn/2 in Oban.Stager.handle_info/2
    (telemetry 1.2.1) /app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (oban 2.18.0) lib/oban/stager.ex:56: Oban.Stager.handle_info/2
Last message: :stage
State: %Oban.Stager{conf: %Oban.Config{dispatch_cooldown: 5, engine: Oban.Engines.Basic, get_dynamic_repo: nil, insert_trigger: true, log: false, name: Oban, node: "45f857b40976", notifier: {Oban.Notifiers.Postgres, []}, peer: {Oban.Peers.Postgres, []}, plugins: [{Oban.Plugins.Cron, [crontab: [{"@hourly", Qultr.EventLinkScraperWorker}]]}, {Oban.Plugins.Pruner, [max_age: 604800]}], prefix: "public", queues: [default: [limit: 5], event_link_watcher: [limit: 1]], repo: Qultr.Repo, shutdown_grace_period: 15000, stage_interval: 1000, testing: :disabled}, timer: #Reference<0.690515242.1288962049.43907>, interval: 1000, limit: 5000, mode: :global}

Possibly related to one of these changes:

Expected Behavior

Not crash

sorentwo commented 1 month ago

Please try forcing a recompile, and/or clearing your build and recompiling. Our tests all failed in CI after the upgrade until we cleared the cache.

sorentwo commented 1 month ago

Closing this for now. If clearing the cache doesn't fix it, let us know.