[erlang-questions] Mnesia doesn't report insertion errors when underlying DETS file is full?

Kenneth Lakin kennethlakin@REDACTED
Sat May 23 07:42:02 CEST 2015


Hi, all. Here's hoping that I'm just misunderstanding how things work.
I've done some searching, but it doesn't seem that anyone has asked this
question on the list before.

I'm testing with Erlang 17.3 (erts 6.2) on AMD64 Kubuntu 15.04.

I wrote a little test program that uses mnesia:write/1 inside of a
mnesia:transaction/1 to write a single integer into a Mnesia
disc_only_copies table. Once the table grows to ~2,097,000 bytes -give
or take-, the the on-disk table file stops growing, and mnesia:info/0
reports that the number of records contained in the table remains constant.

It's obvious that *something* is wrong, as attempts to use mnesia:first
or mnesia:last return {aborted, {badarg, [table]}}. However, the write
operations wrapped in mnesia:transaction keep returning {atomic,
Result}, and comparison between a couple of calls of mnesia:info reveals
that transactions continue to be committed and logged to disk (even
though no new data *sticks around* on disk). I also tested this with
mnesia:activity/2. When the DETS table hits 2GB, mnesia:activity keeps
on trucking: it doesn't throw or exit when called with either
transaction, or async_dirty.

I would have expected mnesia:transaction to return {aborted, table_full}
or something, rather than lying that my data was committed. Is this an
unreasonable expectation? Did the Ubuntu or Debian folks mispackage
Erlang in some way? Is this an oversight on the part of the OTP folks?

For the curious, my program is at the end of this message. (Run it with
test/0.)

Thanks,
-Kenneth Lakin
%%%%%
-module(test).
-compile(export_all).
-record(rec, {key, val}).

test() ->
  %Default to signed intmax iterations.
  test(math:pow(2, 32)/2).
test(Iters) ->
  mnesia:create_schema([node()]),
  mnesia:start(),
  mnesia:wait_for_tables([test], timer:seconds(30)),
  mnesia:clear_table(test),
  mnesia:create_table(test, [{attributes, record_info(fields, rec)},
                             {type, bag},
                             {disc_only_copies, [node()]}
                            ]),
  insertData(Iters).

insertData(Iters) ->
  insertData(0, Iters).
insertData(Step, Iters) when Iters == Step ->
  ok;
insertData(Step, Iters) ->
  F=fun() -> mnesia:write({test, Step, 0}) end,
  %This doesn't seem to throw or exit when
  %inserts fail. Trying mnesia:transaction.
  %mnesia:activity(transaction, F),
  {atomic, _} = mnesia:transaction(F),
  insertData(Step+1, Iters).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150522/5ce397bd/attachment.bin>


More information about the erlang-questions mailing list