Skip to content

Argument error during migration with Ecto.Repo.delete_all/1 #11

@alex-knowles

Description

@alex-knowles

Using prometheus_ecto version 1.3.0, I observe the following stack trace:

** (ArgumentError) argument error
    (stdlib) :ets.lookup(:prometheus_histogram_table, {:default, :ecto_db_query_duration_microseconds, [:ok], 3})
    src/metrics/prometheus_histogram.erl:196: :prometheus_histogram.observe/4
    lib/core/repo_instrumenter.ex:5: Core.RepoInstrumenter.log/1
    lib/core/repo.ex:2: Core.Repo.__log__/1
    (db_connection) lib/db_connection.ex:1186: DBConnection.log/6
    (ecto) lib/ecto/adapters/postgres/connection.ex:73: Ecto.Adapters.Postgres.Connection.prepare_execute/5
    (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
    (ecto) lib/ecto/adapters/sql.ex:426: Ecto.Adapters.SQL.execute_and_cache/7

The Core.RepoInstrumenter module refers to my instrumenter (MyApp.Repo.Instrumenter in the README).

The migration starts by dropping all the rows in a table using Ecto.Repo.delete_all/1. Something like:

MyRepo.delete_all(MySchema)

I can work-around the error by using Ecto.Migration.drop/1 and Ecto.Migration.create/1 in place of delete_all/1:

drop table(:my_table_name)
create table(:my_table_name, primary_key: false) do
  add :foo, :string, null: false
  add :bar, :string, null: false
 # ...
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions