Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alex-knowles opened this issue Oct 25, 2018 · 2 comments
Open

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

alex-knowles opened this issue Oct 25, 2018 · 2 comments

Comments

@alex-knowles
Copy link
Contributor

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
@janpieper
Copy link

We had a similar problem with otter some days ago. :ets.lookup/2 fails with an ArgumentError when the ETS tables does not exist. You may need to start prometheus_ecto.

@alex-knowles
Copy link
Contributor Author

@janpieper wrote:

We had a similar problem with otter some days ago. :ets.lookup/2 fails with an ArgumentError when the ETS tables does not exist. You may need to start prometheus_ecto.

I am pretty new to ETS, but I suspect that the prometheus tables do exist prior to the migration.

For example, when I invoke :ets.all/0, I see :prometheus_histogram_table in the results. Also, if I start Observer from an iex -S mix session and select the Table Viewer I see a number of prometheus tables in the list:

  • prometheus_boolean_table
  • prometheus_counter_table
  • prometheus_gauge_table
  • prometheus_histogram_table
  • prometheus_instrumenter_tests
  • prometheus_registry_table
  • prometheus_summary_table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants