Skip to content

FunctionClauseError after Ecto v3.12 update #146

Closed

Description

@sorentwo

The recent Ecto v3.12 update seems to have broken distinct queries. Here's a full stacktrace, taken from the dependabot update to the Oban repo:

** (FunctionClauseError) no function clause matching in Ecto.Adapters.SQLite3.Connection.distinct/3
    (ecto_sqlite3 0.16.0) lib/ecto/adapters/sqlite3/connection.ex:846: Ecto.Adapters.SQLite3.Connection.distinct(%Ecto.Query.ByExpr{expr: true, file: "/home/runner/work/oban/oban/lib/oban/engines/basic.ex", line: 178, params: nil, subqueries: []}, {{[[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_sqlite3 0.16.0) lib/ecto/adapters/sqlite3/connection.ex:859: Ecto.Adapters.SQLite3.Connection.select/2
    (ecto_sqlite3 0.16.0) lib/ecto/adapters/sqlite3/connection.ex:178: Ecto.Adapters.SQLite3.Connection.all/2
    (ecto_sqlite3 0.16.0) lib/ecto/adapters/sqlite3.ex:187: Ecto.Adapters.SQLite3.prepare/2
    (ecto 3.12.0) lib/ecto/query/planner.ex:202: Ecto.Query.Planner.query_without_cache/4
    (ecto 3.12.0) lib/ecto/query/planner.ex:170: Ecto.Query.Planner.query_prepare/6
    (ecto 3.12.0) lib/ecto/query/planner.ex:143: Ecto.Query.Planner.query_with_cache/8
    (ecto 3.12.0) lib/ecto/repo/queryable.ex:214: Ecto.Repo.Queryable.execute/4
    (ecto 3.12.0) 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) /home/runner/work/oban/oban/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.12.0) lib/ecto/adapters/sql.ex:1382: 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/repo.ex:156: Oban.Repo.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

Here's a link to the failing CI run: https://github.com/sorentwo/oban/actions/runs/10359975065/job/28677500392?pr=1135

Activity

  1. warmwaffles commented on Aug 13, 2024

    @warmwaffles
    Member

    Yea I think I remember seeing something upstream about the distinct changes. I'll try to get this resolved soon.

  2. warmwaffles commented on Aug 13, 2024

    @warmwaffles
    Member

    Leaving this here for later elixir-ecto/ecto_sql#607

  3. self-assigned this
    on Aug 13, 2024
  4. added a commit that references this issue on Aug 14, 2024
    53c4dde
  5. warmwaffles commented on Aug 14, 2024

    @warmwaffles
    Member

    Fix released under v0.17.0

  6. sorentwo commented on Aug 15, 2024

    @sorentwo
    Author

    I can confirm that fixed the issue and got the upgrade passing. Thanks for the quick fix!

  7. added a commit that references this issue on Dec 14, 2024
    0ddc2bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions