Mnesia schema replicas

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Mnesia schema replicas

Vimal Kumar
Hello list,


-QUOTE-
The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table. Adding a node to the list of nodes where the schema is replicated affects the following:

It allows other tables to be replicated to this node.
It causes Mnesia to try to contact the node at startup of disc-full nodes.
-END QUOTE-

I can use the functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 to add and delete replicated copies of other tables successfully, but not table 'schema'. In fact I am not sure at what point in initialization process of a new mnesia node should this be run. Please assist.

------
$ erl -mnesia -sname slave
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
(slave@Vimals-MacBook-Pro)1> mnesia:start().
ok

(slave@Vimals-MacBook-Pro)3> mnesia:change_config(extra_db_nodes, ['server@Vimals-MacBook-Pro']).
{ok,['server@Vimals-MacBook-Pro']}

(slave@Vimals-MacBook-Pro)5> mnesia:add_table_copy(schema, node(), disc_copies).
{aborted,{already_exists,schema,'slave@Vimals-MacBook-Pro'}}
------

Regards,
Vimal

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Mnesia schema replicas

Dan Gudmundsson-3
When you start mnesia without calling create_schema, mnesia will create an empty ram_copies schema for you.

change_config(extra_db_nodes, ..) will connect and merge schema with the server.

What you probably want is to call mnesia:change_table_copy_type(schema, disc_copies, node)) after change_config.

/Dan

On Sun, Feb 7, 2016 at 7:52 PM Vimal Kumar <[hidden email]> wrote:
Hello list,


-QUOTE-
The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table. Adding a node to the list of nodes where the schema is replicated affects the following:

It allows other tables to be replicated to this node.
It causes Mnesia to try to contact the node at startup of disc-full nodes.
-END QUOTE-

I can use the functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 to add and delete replicated copies of other tables successfully, but not table 'schema'. In fact I am not sure at what point in initialization process of a new mnesia node should this be run. Please assist.

------
$ erl -mnesia -sname slave
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
(slave@Vimals-MacBook-Pro)1> mnesia:start().
ok

(slave@Vimals-MacBook-Pro)3> mnesia:change_config(extra_db_nodes, ['server@Vimals-MacBook-Pro']).
{ok,['server@Vimals-MacBook-Pro']}

(slave@Vimals-MacBook-Pro)5> mnesia:add_table_copy(schema, node(), disc_copies).
{aborted,{already_exists,schema,'slave@Vimals-MacBook-Pro'}}
------

Regards,
Vimal
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Mnesia schema replicas

Vimal Kumar
Hi Dan,

On Mon, Feb 8, 2016 at 2:11 PM, Dan Gudmundsson <[hidden email]> wrote:
When you start mnesia without calling create_schema, mnesia will create an empty ram_copies schema for you.

change_config(extra_db_nodes, ..) will connect and merge schema with the server.

What you probably want is to call mnesia:change_table_copy_type(schema, disc_copies, node)) after change_config.


True, and that is what I normally do. However, the documentation says:

"The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table."

Is this statement correct, or a bug in documentation? Has anyone tried to add replica of schema table using mnesia:add_table_copy/3 and succeeded?

Regards,
Vimal
 
/Dan

On Sun, Feb 7, 2016 at 7:52 PM Vimal Kumar <[hidden email]> wrote:
Hello list,


-QUOTE-
The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table. Adding a node to the list of nodes where the schema is replicated affects the following:

It allows other tables to be replicated to this node.
It causes Mnesia to try to contact the node at startup of disc-full nodes.
-END QUOTE-

I can use the functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 to add and delete replicated copies of other tables successfully, but not table 'schema'. In fact I am not sure at what point in initialization process of a new mnesia node should this be run. Please assist.

------
$ erl -mnesia -sname slave
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
(slave@Vimals-MacBook-Pro)1> mnesia:start().
ok

(slave@Vimals-MacBook-Pro)3> mnesia:change_config(extra_db_nodes, ['server@Vimals-MacBook-Pro']).
{ok,['server@Vimals-MacBook-Pro']}

(slave@Vimals-MacBook-Pro)5> mnesia:add_table_copy(schema, node(), disc_copies).
{aborted,{already_exists,schema,'slave@Vimals-MacBook-Pro'}}
------

Regards,
Vimal
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Mnesia schema replicas

Dan Gudmundsson-3
Once upon a time, change_config didn't exist and you added new nodes with add_table_copy, I do think that is still works.

The call to the mnesia:add_table_copy(schema, slaveNode, ram_copies),  must be done
on the server before change_config is done.

/Dan

On Mon, Feb 8, 2016 at 9:59 AM Vimal Kumar <[hidden email]> wrote:
Hi Dan,

On Mon, Feb 8, 2016 at 2:11 PM, Dan Gudmundsson <[hidden email]> wrote:
When you start mnesia without calling create_schema, mnesia will create an empty ram_copies schema for you.

change_config(extra_db_nodes, ..) will connect and merge schema with the server.

What you probably want is to call mnesia:change_table_copy_type(schema, disc_copies, node)) after change_config.


True, and that is what I normally do. However, the documentation says:

"The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table."

Is this statement correct, or a bug in documentation? Has anyone tried to add replica of schema table using mnesia:add_table_copy/3 and succeeded?

Regards,
Vimal
 
/Dan

On Sun, Feb 7, 2016 at 7:52 PM Vimal Kumar <[hidden email]> wrote:
Hello list,


-QUOTE-
The functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 can be used to add and delete replicas of the schema table. Adding a node to the list of nodes where the schema is replicated affects the following:

It allows other tables to be replicated to this node.
It causes Mnesia to try to contact the node at startup of disc-full nodes.
-END QUOTE-

I can use the functions mnesia:add_table_copy/3 and mnesia:del_table_copy/2 to add and delete replicated copies of other tables successfully, but not table 'schema'. In fact I am not sure at what point in initialization process of a new mnesia node should this be run. Please assist.

------
$ erl -mnesia -sname slave
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
(slave@Vimals-MacBook-Pro)1> mnesia:start().
ok

(slave@Vimals-MacBook-Pro)3> mnesia:change_config(extra_db_nodes, ['server@Vimals-MacBook-Pro']).
{ok,['server@Vimals-MacBook-Pro']}

(slave@Vimals-MacBook-Pro)5> mnesia:add_table_copy(schema, node(), disc_copies).
{aborted,{already_exists,schema,'slave@Vimals-MacBook-Pro'}}
------

Regards,
Vimal
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Mnesia schema replicas

Tobias Schlager-2
In reply to this post by Vimal Kumar
Hi Vimal,

I've researched all of this a while ago for this project [1] which manages a dynamically growing/shrinking Mnesia cluster. The source code is full of comments on my findings which may help you. However, the project only uses RAM copies.

Regards
Tobias

[1] https://github.com/lindenbaum/lbm_kv
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions