<div dir="ltr">Thanks, everyone, for the responses. This is all helpful. <div><br></div><div>Regarding what happens if I stop mnesia, create the schema, and restart mnesia - this was how I finally diagnosed what the problem was. IMO this is a hack that I will replace with one of the other techniques mentioned by others. I'm still pondering all this given that there are several nodes sharing the schema.</div><div><br></div><div>Thanks again,</div><div>Rich</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 11, 2014 at 1:30 AM, Dan Gudmundsson <span dir="ltr"><<a href="mailto:dgud@erlang.org" target="_blank">dgud@erlang.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sat, Oct 11, 2014 at 2:48 AM, T Ty <span dir="ltr"><<a href="mailto:tty.erlang@gmail.com" target="_blank">tty.erlang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">The whole lets-create-schema-on-first-start-up-if-it-is-not-there is not worth the aggravation IMHO. Personally I would create the schema as a post-condition to installation or pre-condition to starting the application. </div></blockquote><div><br></div></span><div>That is the intention.</div><div><br></div><div>Or otherwise do a test and create everything dynamically, an empty ram schema is always created if nothing on disc is found.</div><div><br></div><div>Use mnesia:change_table_copy_type(schema, node(), disc_copies). to convert it.</div><div><br></div><div>I believe (long time since I did this) you can even use mnesia:add_table_copy(schema, OtherNode, disc_copies) for the nodes that will start later.</div><div><br></div><div>Create your tables with your distribution configuration.</div><div><br></div><div><div>But do this only ONCE, mnesia will not accept/merge schemas created/modifed from different nodes.</div></div><div><br></div><div>And when starting the empty 'OtherNode ' use the extra_db_nodes config param to initiate mnesia connection </div><div>to the 'Nodes' with a valid schema.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div><div><br></div></div><div>/Dan</div></font></span><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Oct 10, 2014 at 8:51 PM, Youngkin, Rich <span dir="ltr"><<a href="mailto:richard.youngkin@pearson.com" target="_blank">richard.youngkin@pearson.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">Just in case it's helpful to anyone... I've discovered the error of my ways (but I'm still looking towards a solution). This application used to start Mnesia directly after creating the schema (only on the initial startup of course). When creating the release I changed this by adding the mnesia application to the {applications, [...]} tuple in the app.src file. I did this to fix another problem caused by the Mnesia beam files not being included as part of the Erlang distro created by relx. So in the release version, Mnesia is up and running before the schema is created. So I end up with a started Mnesia application without a schema, which of course is needed to define tables.<div><br></div><div>So now on the my next question, how can I get the schema initialized if Mnesia is started prior to schema creation? Some guy who gives crappy answers :) had this post in StackOverflow that gave a partial answer - <a href="http://stackoverflow.com/questions/14083367/mnesia-doesnt-restart-with-supervisor" target="_blank">http://stackoverflow.com/questions/14083367/mnesia-doesnt-restart-with-supervisor</a>. Is this really the preferred way of doing this? Seems like a bit of a hack to me (but I'm still a newbie, what do I know :>).<br><div><br></div><div>Cheers,</div><div>Rich</div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 8:33 AM, Youngkin, Rich <span dir="ltr"><<a href="mailto:richard.youngkin@pearson.com" target="_blank">richard.youngkin@pearson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I recently converted an existing application to a release using relx. After that the application isn't able to create any Mnesia tables. I can't reproduce the problem in the Erlang shell (except by creating the table before creating the schema). This is confusing because the app code creates the schema prior to creating the table.</div><div><br></div><div>Here is the error:</div><div><div>12:20:18.929 [info] Creating a new schema from scratch...</div><div>12:20:18.929 [info] Mnesia started, creating tables...</div><div>12:20:18.929 [info] Attempting to create table with TableDef {pe_properties,{disc_copies,[{attributes,[key,value]},{record_name,pe_kvpair}]}}</div><div>12:20:18.931 [error] gen_server pe_membership terminated with reason: bad return value: {error,{unable_to_init_schema,{aborted,{bad_type,pe_properties,disc_copies,'<a href="mailto:prospero@subpubone.ecollege-dev.com" target="_blank">prospero@subpubone.ecollege-dev.com</a>'}}}}</div></div><div><br></div><div><br></div><div>Here's the associated application code:<br></div><div>
<p> error_logger:info_msg("Creating a new schema from scratch...~n"),</p><p> %% TODO: TEMP WORKAROUND TO DEBUG MNESIA SCHEMA CREATION PROBLEM</p><p> application:set_env(mnesia, dir, "/var/data/prospero"),</p><p> mnesia:create_schema([node()]),</p><p> mnesia:start(),</p><p> error_logger:info_msg("Mnesia started, creating tables...", []),</p><p> case create_tables(pe_migrate:get_schema()) of</p><p><br></p><p>The line application:set_env(...) was added in case the Mnesia directory wasn't getting created properly due to the move to a relx-built release. I had a similar entry in vm.args that I may have gotten wrong (-mnesia dir '"/var/data/prospero"'). Interestingly enough, I don't see any artifacts associated with the schema creation in the Mnesia dir (e.g., schema.DAT). I'm wondering if this is a clue as to what the cause is.</p><p>pe_migrate:get_schema()) returns a list of TableDefs. create_tables iterates through that list creating the tables one at a time. The failure occurs when attempting to create the first table.<br></p><p>Thanks, Rich</p></div></div>
</blockquote></div><br></div>
</div></div><br></div></div><span>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></span></blockquote></div><br></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>