Erlang Mailing Lists

Author Message

<  Erlang questions mailing list  ~  mnesia question: full database replication across the sever

chandru.m
Posted: Fri Aug 28, 2009 12:28 pm Reply with quote
User Joined: 24 Oct 2007 Posts: 85
2009/8/28 Eugen Sobchenko <esobchenko@gmail.com>

> Hi! I have a distributed mnesia application that have to create new
> tables during it's work.
> I want to keep all tables replicated on all mnesia nodes in my
> cluster.
> What if the table has been created at the moment when some of the
> cluster nodes were down? Is there a standard solution to make full
> database replication across the several nodes?
>

Table creation will fail if one (or more) of the nodes you've specified for
table copies is not reachable. If you want it to succeed regardless of some
nodes not being reachable, you have to create your table on whatever nodes
exist, and have some code which makes copies of tables when nodes come up.

cheers
Chandru


Post received from mailinglist
View user's profile Send private message
warezio
Posted: Fri Aug 28, 2009 3:43 pm Reply with quote
User Joined: 05 May 2007 Posts: 107 Location: Yahoo
I wrote something called fragmentron originally intended for mnesia on
EC2. It takes a desired number of data copies for a table. If you set
this to a huge number (e.g., 999), you would get full replication of
everything everywhere.

http://code.google.com/p/fragmentron/

-- p

On Fri, 28 Aug 2009, Chandru wrote:

> 2009/8/28 Eugen Sobchenko <esobchenko@gmail.com>
>
> > Hi! I have a distributed mnesia application that have to create new
> > tables during it's work.
> > I want to keep all tables replicated on all mnesia nodes in my
> > cluster.
> > What if the table has been created at the moment when some of the
> > cluster nodes were down? Is there a standard solution to make full
> > database replication across the several nodes?
> >
>
> Table creation will fail if one (or more) of the nodes you've specified for
> table copies is not reachable. If you want it to succeed regardless of some
> nodes not being reachable, you have to create your table on whatever nodes
> exist, and have some code which makes copies of tables when nodes come up.
>
> cheers
> Chandru
>


________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org

Post received from mailinglist
View user's profile Send private message Yahoo Messenger
warezio
Posted: Fri Aug 28, 2009 3:56 pm Reply with quote
User Joined: 05 May 2007 Posts: 107 Location: Yahoo
Thinking about your exact problem, however, it's probably simplest just to
have each node add the table copies to itself when it starts up.
Something like

mnesia:add_table_copy (TheTable, node (), TheTableType)

where TheTable is the table name (e.g., 'mytable') and TheTableType is
one of 'ram_copies', 'disc_copies', or 'disc_only_copies'.
mnesia:add_table_copy/3 is idempotent so this is relatively harmless to do
every time. It does create a schema transaction, which can be slow under
extreme load. I used the following "dirty schema read" to make things
faster in the case where typically the table already has a local copy.

-----------

fast_add_table_copy (TableName, Node, CopyType) ->
try lists:member (Node, used_nodes (TableName)) of
true -> { aborted, { already_exists, TableName, Node } };
false -> mnesia:add_table_copy (TableName, Node, CopyType)
catch
_ : _ ->
{ aborted, { no_exists, TableName } }
end.

used_nodes (TableName) ->
lists:usort (used_nodes (TableName, ram_copies) ++
used_nodes (TableName, disc_copies) ++
used_nodes (TableName, disc_only_copies)).

used_nodes (TableName, CopyType) ->
mnesia:table_info (TableName, CopyType).

-----------

Cheers,

-- p

On Fri, 28 Aug 2009, Paul Mineiro wrote:

> I wrote something called fragmentron originally intended for mnesia on
> EC2. It takes a desired number of data copies for a table. If you set
> this to a huge number (e.g., 999), you would get full replication of
> everything everywhere.
>
> http://code.google.com/p/fragmentron/
>
> -- p
>
> On Fri, 28 Aug 2009, Chandru wrote:
>
> > 2009/8/28 Eugen Sobchenko <esobchenko@gmail.com>
> >
> > > Hi! I have a distributed mnesia application that have to create new
> > > tables during it's work.
> > > I want to keep all tables replicated on all mnesia nodes in my
> > > cluster.
> > > What if the table has been created at the moment when some of the
> > > cluster nodes were down? Is there a standard solution to make full
> > > database replication across the several nodes?
> > >
> >
> > Table creation will fail if one (or more) of the nodes you've specified for
> > table copies is not reachable. If you want it to succeed regardless of some
> > nodes not being reachable, you have to create your table on whatever nodes
> > exist, and have some code which makes copies of tables when nodes come up.
> >
> > cheers
> > Chandru
> >
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org

Post received from mailinglist
View user's profile Send private message Yahoo Messenger

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum