LFE and ETS ...

70 views
Skip to first unread message

Duncan McGreggor

unread,
May 19, 2019, 10:33:29 PM5/19/19
to Lisp Flavoured Erlang
I don't know if I've ever played with ETS before in LFE ... definitely Mnesia, but I can't remember using ETS before.

So, naturally, I have some questions :-)

Something that I noticed in the LFE REPL: when getting an exception error (e.g., calling an Erlang stdlib mod:func with args in the wrong order), I could no longer access my ETS table. Upon digging, I saw that the LFE pid was changing every time an exception was thrown. Is that new with 1.3? (To date, most of my LFE use has been pre-1.0, and the remainder has been with 1.2) Maybe the pid has changed every time there was an exception in the REPL, and this is the first time I've noticed (or I have forgotten!)?

Seeing this, of course, made sense of the ETS table going away, since that's tied to the process that starts it. Not a biggie, though -- I'm exploring storing config data for a library in ETS, to take lookups off the filesystem. If the process crashes, I can just re-read from disk ...

d

Fred Hebert

unread,
May 20, 2019, 11:59:24 AM5/20/19
to lisp-flavo...@googlegroups.com
The Erlang shell  works the same way. Usually people will use a worker or supervisor to own the ETS table and make sure it won’t crash. If t does crash, there’s the ability to set heirs and give tables away as well.

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-e...@googlegroups.com.
To post to this group, send email to lisp-flavo...@googlegroups.com.
Visit this group at https://groups.google.com/group/lisp-flavoured-erlang.
To view this discussion on the web visit https://groups.google.com/d/msgid/lisp-flavoured-erlang/47c8f4db-ec14-4dc6-b1db-2e92bbbdc2d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Duncan McGreggor

unread,
May 20, 2019, 1:07:15 PM5/20/19
to Lisp Flavoured Erlang
Perfect, Fred -- thanks! (and, yeah -- that's the approach I'm using for the lib: the supervisor is going to create the table).

Oh, wow ... I _didn't_ know about setting heirs and giving tables away; VERY cool. I'll re-read (well read instead of skim) the Bears-ETS-Beets chapter to see where I missed that ...

THANKS!

d


Dave Cottlehuber

unread,
May 29, 2019, 6:31:48 AM5/29/19
to lisp-flavo...@googlegroups.com
On Mon, 20 May 2019, at 17:07, Duncan McGreggor wrote:
> Perfect, Fred -- thanks! (and, yeah -- that's the approach I'm using
> for the lib: the supervisor is going to create the table).
>
> Oh, wow ... I _didn't_ know about setting heirs and giving tables away;
> VERY cool. I'll re-read (well read instead of skim) the Bears-ETS-Beets
> chapter to see where I missed that ...
>
> THANKS!
>
> d

There's some prior art if that helps.

https://steve.vinoski.net/blog/2011/03/23/dont-lose-your-ets-tables/
https://github.com/DeadZen/etsgive & https://github.com/whitfin/eternal are my favourites

A+
Dave

Robert Virding

unread,
Jun 3, 2019, 8:18:33 AM6/3/19
to Lisp Flavoured Erlang
Yes, I modelled (copied) the LFE repl on the Erlang shell. They seem more processy than the Elixir shell which doesn't die as often.

Robert


On Monday, 20 May 2019 17:59:24 UTC+2, Fred Hebert wrote:
The Erlang shell  works the same way. Usually people will use a worker or supervisor to own the ETS table and make sure it won’t crash. If t does crash, there’s the ability to set heirs and give tables away as well.
On Sun, May 19, 2019 at 22:33 Duncan McGreggor <dun...@mcgreggor.org> wrote:
I don't know if I've ever played with ETS before in LFE ... definitely Mnesia, but I can't remember using ETS before.

So, naturally, I have some questions :-)

Something that I noticed in the LFE REPL: when getting an exception error (e.g., calling an Erlang stdlib mod:func with args in the wrong order), I could no longer access my ETS table. Upon digging, I saw that the LFE pid was changing every time an exception was thrown. Is that new with 1.3? (To date, most of my LFE use has been pre-1.0, and the remainder has been with 1.2) Maybe the pid has changed every time there was an exception in the REPL, and this is the first time I've noticed (or I have forgotten!)?

Seeing this, of course, made sense of the ETS table going away, since that's tied to the process that starts it. Not a biggie, though -- I'm exploring storing config data for a library in ETS, to take lookups off the filesystem. If the process crashes, I can just re-read from disk ...

d

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-erlang+unsub...@googlegroups.com.
To post to this group, send email to lisp-flavoured-erlang@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages