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

Why am I getting :no_exists on :id_seq #26

Open
rschooley opened this issue Feb 21, 2017 · 11 comments
Open

Why am I getting :no_exists on :id_seq #26

rschooley opened this issue Feb 21, 2017 · 11 comments

Comments

@rschooley
Copy link

test/models/user_test.exs:42
 ** (exit) {:aborted, {:no_exists, :id_seq}}
 stacktrace:
   (mnesia) mnesia.erl:318: :mnesia.abort/1
   (mnesia) mnesia.erl:1610: :mnesia.do_dirty_update_counter/4
   (ecto_mnesia) lib/ecto_mnesia/adapter.ex:239: anonymous fn/2 in Ecto.Mnesia.Adapter.put_new_pk/3
   (elixir) lib/keyword.ex:242: Keyword.get_and_update/4
   (ecto_mnesia) lib/ecto_mnesia/adapter.ex:238: Ecto.Mnesia.Adapter.put_new_pk/3
   (ecto_mnesia) lib/ecto_mnesia/adapter.ex:222: Ecto.Mnesia.Adapter.do_insert/4
   (ecto) lib/ecto/repo/schema.ex:459: Ecto.Repo.Schema.apply/4
   (ecto) lib/ecto/repo/schema.ex:198: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4
   test/models/user_test.exs:43: (test)

my migration is (I've tried :set as well)

create_if_not_exists table(:users) do
  add :email, :string
  add :password_hash, :string

  timestamps()
end

I see an id_seq table in mnesia, but it is empty. Does it need to be seeded with something or did I do something else wrong? Thanks for the help.

@AndrewDryga
Copy link
Member

Can you show what shell commands do you run? Basically whenever a table is created we should insert a new record into id_seq table that will store sequence number. And it looks like record or whole table does not exist (was not created on migration).

@gallexme
Copy link

gallexme commented Mar 14, 2017

@AndrewDryga
#27:
mix ecto.migrate
then running my umbrella project with mix phx.server
when i do then insert/get whatever something I get the id_seq error

edit: @AndrewDryga if you need anymore infos please tell me and btw im using windows 10

@gallexme
Copy link

@AndrewDryga
Copy link
Member

@gallexme thanks, I'll look into it.

@AndrewDryga
Copy link
Member

@gallexme you need to create directory for Mnesia files first, try to call mix ecto.create. If it fails, just manually create this path. (You can persist in in git by adding empty .gitkeep file into it.)

Also you will need to add config :crypto_exchange_web, ecto_repos: [] to crypto_exchange_web application, to tell ecto migrator that you don't have repos in this app.

@gallexme
Copy link

The Patch exists on my pc and
Actually what I found out is that when I use the Mix task it create The folder under crypto_exchange_data/priv
And when I run The umbrella and use mnesia.info it shows a different Patch umbrella/priv

And the other issue is just a warning it shouldnt matter as the Web App doesn't even have ecto

@gallexme
Copy link

Sorry was written on my phone Patch means path

@walkr
Copy link

walkr commented Apr 20, 2017

I'm getting this similar error {:aborted, {:no_exists, :id_seq}}

In my case the error is triggered when starting my node named.

# It works
$ elixir --cookie cookie123 -S mix phoenix.server

# Does not work (triggers the error)
$ elixir --name [email protected] --cookie cookie123 -S mix phoenix.server

This is a serious limitation, and it should probably be addressed!

Cheers!

@AndrewDryga
Copy link
Member

@walkr try to:

  • run migrations from named instance;
  • set a custom Mnesia dir. Mnesia stores data in folder with host name, and when you change host name maybe it just don't see migrated DB schema;
  • try sname instead of name.

In general, It's not an adapter limitation, rather you should dig deeper into Mnesia details.

@walkr
Copy link

walkr commented Apr 21, 2017

@AndrewDryga Thanks!

I've actually ended up fixing the problem, but bumped into another one.

I've solved the problem by supplying the settings on the adapter in the config.exs instead of :ecto_mnesia as it is suggested in the README.

Example

config :my_app, MyApp.Mnesia.Repo,
  adapter: EctoMnesia.Adapter,
  priv: "priv/repo_mnesia",
  host: {:system, :atom, "MNESIA_HOST", Kernel.node()},
  storage_type: {:system, :atom, "MNESIA_STORAGE_TYPE", :disc_copies}

However, now I'm bumping into the same {:aborted, {:no_exists, :id_seq}} when I'm using ram_copies.

@AndrewDryga
Copy link
Member

For RAM copies you need to make sure that you run migrations on each time Erlang VM node starts. And this is a adapters part that could be automated. I'll add separate issue for it.

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

4 participants