Re: mnesia:transaction aborting
Dániel Szoboszlay <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CADcfxo=C40YhBBKvCGgJYFafOxWS7hFb-vT13huv+X4LioVzRA@mail.gmail.com> |
If there are 0 records in the pw_usr_record table, the wread will return [], not [Usr], so your transaction will fail due to case_clause. Or am I missing something? Cheers, Daniel On Mon, 25 Jan 2021 at 03:57, Peter J Etheridge <[email protected]> wrote: > Dear Fellow Erlangers, > > I run; > > mnesia:transaction(fun() -> > case mnesia:wread({pw_usr_record, pw_un}) of > [Usr] -> > Usr = #pw_usr_record{pw_un = Username, pw_pas = Password}, > mnesia:write(pw_usr_record, Usr, write), > catch mnesia:abort("aborted") > end > end), > > result; > > mnesia:info(). > ---> Processes holding locks <--- > ---> Processes waiting for locks <--- > ---> Participant transactions <--- > ---> Coordinator transactions <--- > ---> Uncertain transactions <--- > ---> Active tables <--- > pw_usr_record : with 0 records occupying 305 words of mem > schema : with 2 records occupying 533 words of mem > ===> System info in version "4.17", debug level = verbose <=== > opt_disc. Directory > "/home/kanga/Documents/ebin/include/priv/src/Mnesia.nonode@nohost" is > used. > use fallback at restart = false > running db nodes = [nonode@nohost] > stopped db nodes = [] > master node tables = [] > remote = [] > ram_copies = [pw_usr_record] > disc_copies = [schema] > disc_only_copies = [] > [{nonode@nohost,disc_copies}] = [schema] > [{nonode@nohost,ram_copies}] = [pw_usr_record] > 3 transactions committed, 1 aborted, 0 restarted, 2 logged to disc > 0 held locks, 0 in queue; 0 local transactions, 0 remote > 0 transactions waits for other nodes: [] > ok > > As shown above, instead of writing (0 records shown) the transaction is > aborting (1 aborted). > > Could the Variable be out of scope? > > Where else might I look? > > Thank you in advance, > > Peter > > > > >