[erlang-questions] Mnesia create tables best practices

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sun Feb 8 16:47:38 CET 2015

On Sat, Feb 7, 2015 at 7:45 PM, Roberto Ostinelli <roberto@REDACTED>

> Dear list,
> What best practice do you have when you have a release and want to insure
> a node has a properly initialised mnesia scheme?

Provide a pre-initialized database with your release. Don't attempt
"figuring out" if there is no database and then create it on demand. It
just leads to misery.

Your system proper only operates if there is a database. The End. When the
release initially boots, there is a complete database, with a complete
schema, ready to run, so the nodes can start working immediately. Some
times, you will me using a method, where there is a file named
FALLBACK.BUP. This is a "fallback" file, which will "restore" the database
once the system is booted. This is also how `mnesia:create_schema/2` works,
incidentally :P

The beauty of this way is that your system is always in a state where it is
"catching up" from a known good state. And you don't have to handle the
special case of "initializing", which is completely perpendicular to your
normal operation.

Unfortunately, creation of Mnesia databases is not an idempotent operation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150208/4ccfe1ea/attachment.htm>

More information about the erlang-questions mailing list