[erlang-questions] mnesia starting and then droping schema

Richard Andrews bflatmaj7th@REDACTED
Mon Aug 3 13:23:51 CEST 2009


2009/8/3 paweł kamiński <kamiseq@REDACTED>:
> hi,
> im totally new to mnesia, I went through chapter about mnesia db and tried
> to run code from the Joe's book.
> I managed to create schema of few tables, then I started and waited for
> tables with wait_for_tables/2 but all I got was timeout
>
> then I tried dropping the schema I just created but I got error that db is
> running on other nodes (nonode@REDACTED - the default from emacs shell) and I
> cant drop it.......
>
> should I run my script from sasl or start something before???

Yeah. I had trouble with disk nodes when I started using mnesia too.

Here's the basics:
 * You can only call create_schema before starting the mnesia
application (more precisely when the app is not running). So either
have a separate program to do it or detect the missing schema and
create it; but you have to do this *before* you start the mnesia
application. I usually make a script or command line flag to do it.
 * Mnesia startup expects the schema to be present if you specify a
disc node. You can then create tables and call wait_for_tables to wait
while mnesia synchronises.
 * You can only safely remove the schema when mnesia is stopped; same
principle as for creating. You can however stop mnesia, delete and
create the schema and restart.

>From man mnesia (R12B4):

              mnesia:create_schema/1 fails if any of the Erlang nodes
given as DiscNodes are  not
              alive,  if  Mnesia  is  running  on  anyone of the
nodes, or if anyone of the nodes
              already has a schema. Use mnesia:delete_schema/1 to get
rid of old faulty  schemas.

This has implications for adding mnesia to your own .app file.

HTH
--
  Rich


More information about the erlang-questions mailing list