patch to mnesia

Hakan Mattsson hakan@REDACTED
Mon Sep 4 17:15:04 CEST 2000


On Mon, 4 Sep 2000 luc.taesch@REDACTED wrote:

> >    The external textfile format is not intended to be used
> >    in real products. Please, follow the advice in the Mnesia
> >    man-page:
> > 
> > 	"Only use this function for educational purposes.
> >         Use other functions to deal with real backups."
> > 
> 
> in fact , im not using it for backups, but during the evolutionary phase of 
> development. we have a very short cycle, XP style, and we find convenient to be 
> able to dump the db to textfiles, 
> -either to preserve the data in case of break of  the schema ( and we can at 
> least edit by hand the existing data),

If you with "break of the schema" mean that the database schema file is broken
you should use the backup utilities to protect your system.

If you with "break of the schema" mean that you have changed the
record definitions you may either use mnesia:transform_table to
perform on-line changes of the schema or apply mnesia:traverse_backup
on a backup if you prefer to do it off-line.

> - or to prepare test data, especially when the (editing) front end is not ready 
> for inputing.
> 
> any comments ?
> if u have any idea on adapting schema more automatically, ure most welcomed !

The functions in Mnesia that deals with the textual format
(mnesia:dump_to_textfile/1 and mnesia:load_textfile/1) has many
shortcomings, such as:

   - the file format is vulnerable for crashes
   - only local data is handled
   - only a subset of Erlang's data types is handled
   - only designed to cope with small tables
   - ...

The internal file format (tables, logs, backups) in Mnesia has been
designed with crash recovery in mind. Even if the filesystem gets
currupt and later fixed by fsck, Mnesia can in most cases repair its
files (sometimes by discarding corrupt data) and be able to
start. During development and testing this default behaviour may
suffice.

But in order to be able to recover from any kind of failures you must
backup your system regulary to a media separate from the database
media (at least to another disk partition, but preferrably to a remote
disk or tape situated at another geographical location). The Mnesia
backup utilities with its callback API is designed to cope with this.

Instead of editing the plain textfile you may use the table viewer
tool (tv) which has the ability of editing tables. You may either
edit the database directly on-line or perform the edits off-line
in a mirror database.

/Håkan

---
Håkan Mattsson
Ericsson
Computer Science Laboratory
http://www.ericsson.se/cslab/~hakan





More information about the erlang-questions mailing list