madasebrof

madasebrof

I just upgraded to Elixir 1.8.1 after running 1.5 for a few years (rock solid, fyi–THANKS!!!)

I’m posting this because I use Elixir on a daily basis and have never come across this issue.

Basically, I modified an existing function Polo.Sim.Model.Ids.insert_start_end_date/2, then reloaded it in IEx. (The function was not itself running in a GenServer, but rather a function being called by another Genserver)

iex> r Polo.Sim.Model.Ids  
{:reloaded, Polo.Sim.Model.Ids, [Polo.Sim.Model.Ids]}
iex> 

Great, working, fine, as you can see below.

Then, the system tried to auto-recompile (I guess it detected changes I made), but then the app crashed with an UndefinedFunctionError.

I also am running a Phoenix 1.4/Ecto app, but since this is really backend stuff, I thought I’d post here.

[info] Updating holdings in Polo.Sim.Model.Holdings for [100675]...
[info] [100675] start_date = 2014-03-19 (oem = 2014-03-31), end_date = 2019-10-31
[info] Updating holdings in Polo.Sim.Model.Holdings for [100676]...
[info] [100676] start_date = 2019-04-11 (oem = 2019-04-30), end_date = 2019-10-31
[info] Loading model_id [100677] Parsley Energy Inc into Polo.Sim.Server...

warning: redefining module Polo.Sim.Model.Ids (current version loaded from _build/dev/lib/polo/ebin/Elixir.Polo.Sim.Model.Ids.beam)
  lib/polo/sim/model/ids.ex:1

[info] Updating holdings in Polo.Sim.Model.Holdings for [100677]...
[info] [100677] start_date = 2014-05-23 (oem = 2014-05-31), end_date = 2019-10-31

.... (works for a while...)

[info] [100717] start_date = 2007-01-03 (first_end_date = 2007-01-31) end_date = 2019-10-31
[info] Loading model_id [100718] Pure Storage Inc into Polo.Sim.Server...
[info] Updating holdings in Polo.Sim.Model.Holdings for [100718]...
[info] [100718] start_date = 2015-10-07 (first_end_date = 2015-10-31) end_date = 2019-10-31
[info] Loading model_id [100719] Phillips 66 into Polo.Sim.Server...
[info] Updating holdings in Polo.Sim.Model.Holdings for [100719]...
[info] [100719] start_date = 2012-04-12 (first_end_date = 2012-04-30) end_date = 2019-10-31
[info] Loading model_id [100720] PTC Inc into Polo.Sim.Server...
[info] Updating holdings in Polo.Sim.Model.Holdings for [100720]...
[info] [100720] start_date = 2007-01-03 (first_end_date = 2007-01-31) end_date = 2019-10-31
[info] Loading model_id [100721] PVH Corp into Polo.Sim.Server...
Compiling 34 files (.ex)
[info] Updating holdings in Polo.Sim.Model.Holdings for [100721]...
[error] GenServer Polo.Sim.Server terminating
** (UndefinedFunctionError) function Polo.Sim.Model.Ids.insert_start_end_date/2 is undefined (module Polo.Sim.Model.Ids is not available)
    (elixir) lib/enum.ex:769: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:769: Enum.each/2
    (polo) lib/polo/sim/server/server.ex:539: Polo.Sim.Server.update_data/0
    (polo) lib/polo/sim/server/server.ex:518: Polo.Sim.Server.handle_cast/2
    (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", :update}
Compiling lib/polo/web/views/signing_view.ex (it's taking more than 15s)
Compiling lib/polo/web/views/portfolio_view.ex (it's taking more than 15s)
Etc...

Its happened a few time today already (e.g. modifying a function, reloading it in IEx, working for a while, then blowing up on auto-recompile)

Thoughts?

Thanks in advance!!!

Showing Posts 1 to 1

a-maze-d

a-maze-d

I know I’m late to the party, since it has been a while since you posted this question, but I experience something similar in a livebook and here are my thoughts related to this. Let’s start what my issue was:

I defined a GenServer in my livebook which executes some user defined functions. Thus, the code look something like this:

def myfunc(arg) do
  # do something in here 
end
GenServer.call(server, {:func, &myfunc/1})

The GenServerrepeatedly called the function in certain time intervals.

This all worked just fine, until I redefined the function to do something else, because suddenly I received the UndefinedFunctionError from the GenServer (Note: not from defining my function).

Instead of using named functions I used anonymous functions and suddenly the problem disappeared.

I suspect that the issue is with redefining the function (in one process) and accessing that function (through a reference) in another process. The first process has dropped the function (still referenced by the other process) and the other process hasn’t caught up with the change (yet!?). I’m not sure if the other process would catch up at all… I never investigated this.

Your description sounds very similar to this and therefore I would suspect that you have a similar issue.

With my assumptions and my (limited) understanding of Elixir/Erlang, I don’t think this is a bug in Elixir. I"m not even sure it’s a bug in Erlang, even though it would be nice if the function does not get dropped until all processes have caught up with the redefinition.

Maybe the above also helps for some more wise Elixir/Erlang people :slight_smile: to make that judgement call

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews