[erlang-questions] Ridiculuous newbie mnesia question.

Jeffrey Rennie surferjeff@REDACTED
Mon Oct 25 07:30:31 CEST 2010


I launched a new erl node with a proper -sname, and I'm still experiencing
the same problem.  Yes, nodes a@REDACTED and b@REDACTED are up and running.

(emacs@REDACTED)17> backgammon:init().
{atomic,ok}
(emacs@REDACTED)18> backgammon:insert_game(1, "Jeff").
{aborted,{no_exists,game_record}}
(emacs@REDACTED)19> backgammon:init().
{aborted,{already_exists,game_record}}
(emacs@REDACTED)20> mnesia:info().
---> Processes holding locks <--- 
---> Processes waiting for locks <--- 
---> Participant transactions <--- 
---> Coordinator transactions <---
---> Uncertain transactions <--- 
---> Active tables <--- 
schema         : with 3        records occupying 656      words of mem
===> System info in version "4.4.13", debug level = none <===
opt_disc. Directory
"c:/Users/jeff/code/code/scratch/erlang/Mnesia.emacs@REDACTED" is NOT used.
use fallback at restart = false
running db nodes   = [emacs@REDACTED]
stopped db nodes   = [] 
master node tables = []
remote             = [backgammon_games,game_record]
ram_copies         = [schema]
disc_copies        = []
disc_only_copies   = []
[] = [backgammon_games,game_record]
[{emacs@REDACTED,ram_copies}] = [schema]
4 transactions committed, 3 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
ok
(emacs@REDACTED)21> mnesia:delete_table(backgammon_games).
{aborted,{no_exists,backgammon_games}}
(emacs@REDACTED)22> mnesia:delete_table(game_record).
{aborted,{no_exists,game_record}}
 (emacs@REDACTED)23> backgammon:init().
{aborted,{already_exists,game_record}}
(emacs@REDACTED)24>


> -----Original Message-----
> From: Ulf Wiger [mailto:ulf.wiger@REDACTED]
> Sent: Sunday, October 24, 2010 3:02 PM
> To: Jeffrey Rennie
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] Ridiculuous newbie mnesia question.
> 
> 
> Hi Jeffrey,
> 
> The problem is that you have specified that the backgammon_games
> table should have copies on a@REDACTED and b@REDACTED, but your
> Erlang shell has the node name nonode@REDACTED (i.e. Erlang was
> started without distribution).
> 
> One might argue whether it wouldn't have been better if mnesia had
> refused to create the table in the first place. As it is now, it
> believes
> it exists, because there is an entry in the schema, but it refuses to
> delete it because it has no active replicas. But since that's not what
> it
> complains about, I can understand your confusion. :)
> 
> BR,
> Ulf W
> 
> 
> On 24 Oct 2010, at 23:37, Jeffrey Rennie wrote:
> 
> > I seem to be stuck in a state where I can't create a table because it
> > exists, but I can't delete the table because it doesn't exist!
> >
> > I searched the mnesia documentation, and I couldn't find a definition
> > of the "Tab" arg passed to many mnesia functions.
> >
> > Here's what I tried:
> >
> > Eshell V5.7.5  (abort with ^G)
> > 2> c(backgammon).
> > {ok,backgammon}
> > 5> c(backgammon).
> > {ok,backgammon}
> > 7> mnesia:start().
> > ok
> > 8> backgammon:init().
> > {atomic,ok}
> > 11> c(backgammon).
> > {ok,backgammon}
> > 12> backgammon:dumpfields().
> > [player_turn,dice,board]
> > 13> c(backgammon).
> > {ok,backgammon}
> > 14> backgammon:init().
> > {aborted,{already_exists,backgammon_games}}
> > 15> mnesia:info().
> > ---> Processes holding locks <---
> > ---> Processes waiting for locks <---
> > ---> Participant transactions <---
> > ---> Coordinator transactions <---
> > ---> Uncertain transactions <---
> > ---> Active tables <---
> > schema         : with 2        records occupying 546      words of
> mem
> > ===> System info in version "4.4.13", debug level = none <===
> > opt_disc. Directory
> > "c:/Users/jeff/code/code/scratch/erlang/Mnesia.nonode@REDACTED" is NOT
> > used.
> > use fallback at restart = false
> > running db nodes   = [nonode@REDACTED]
> > stopped db nodes   = []
> > master node tables = []
> > remote             = [backgammon_games]
> > ram_copies         = [schema]
> > disc_copies        = []
> > disc_only_copies   = []
> > [] = [backgammon_games]
> > [{nonode@REDACTED,ram_copies}] = [schema]
> > 3 transactions committed, 1 aborted, 0 restarted, 0 logged to disc
> > 0 held locks, 0 in queue; 0 local transactions, 0 remote
> > 0 transactions waits for other nodes: []
> > ok
> > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> > %% BEGIN CONFUSING BIT
> > 17> mnesia:delete_table(backgammon_games).
> > {aborted,{no_exists,backgammon_games}}
> > 18> backgammon:init().
> > {aborted,{already_exists,backgammon_games}}
> > 19>
> > %% END CONFUSING BIT
> > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> >
> >
> > Here's my backgammon.erl:
> > -module(backgammon).
> >
> > -compile(export_all).
> >
> > -include("backgammon.hrl").
> >
> > create_tables(MnesiaNodes) ->
> >    mnesia:create_table(backgammon_games,
> > 			[{attributes, record_info(fields, game_record)},
> > 			 {ram_copies, MnesiaNodes}]).
> >
> > init() ->
> >    create_tables([a@REDACTED, b@REDACTED]).
> >
> > dumpfields() ->
> >    record_info(fields, game_state).
> >
> > ________________________________________________________________
> > erlang-questions (at) erlang.org mailing list.
> > See http://www.erlang.org/faq.html
> > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> >
> 
> Ulf Wiger, CTO, Erlang Solutions, Ltd.
> http://erlang-solutions.com
> 





More information about the erlang-questions mailing list