mnesia:transaction aborting
Dániel Szoboszlay
dszoboszlay@REDACTED
Mon Jan 25 11:00:29 CET 2021
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 <petergi@REDACTED>
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@REDACTED" is
> used.
> use fallback at restart = false
> running db nodes = [nonode@REDACTED]
> stopped db nodes = []
> master node tables = []
> remote = []
> ram_copies = [pw_usr_record]
> disc_copies = [schema]
> disc_only_copies = []
> [{nonode@REDACTED,disc_copies}] = [schema]
> [{nonode@REDACTED,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
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210125/5505ebc6/attachment.htm>
More information about the erlang-questions
mailing list