henriquesati

henriquesati

Can I trust task and spawn to finalize instructions without being supervised?


this is my current project structure, the get request has a field that needs external validation
the idea is the endpint dispatch the validation async to a task or spawn (for what I researched, if I dont need a explicity return, spawn its more lightweith and swits me more) and then retrieve the result with a get request via another endpoint, and leave tha
the task to registry the result on the ets and the db, the possible states for the value
would be
value = processing
value = acceptd (waiting for payment)
value = denied ({error, reason}
can I trust the task to perform all its duties without being supervised?
the info registered on db will have a timestamp of 2 or 3 mins, after this everything will be dropped, so it the get request doesnt find the value on the ets for any reason (if too many request hits the post endpoint, the value may be dropped from the ets, I will yet think on the cache logic) neither on the db, it can be assumed that the response was {:error, reason}, but fot that I need to trust that everything delegated to the the asyncs will be executed
also, do I need to protect my system against ets random crashs? and if yes, besides using supervisor to restart it there is a way to retrieve the data?
fyi, the application will be running on cloud with 2cpu and 3gb ram

Most Liked

kip

kip

ex_cldr Core Team

As @dimitarvp says, if ETS itself crashes, that’s an OTP bug. However ETS tables are owned by a process and the tables disappear when the process exits (for whatever reason). So you may benefit from some additional resilience around the owner process. For that, ETS provides an heir option to :ets.new/2. If the owning process dies, then the heir process will take ownership.

The eternal library helps keep ETS table alive even when the owner process dies using the heir mechanism.

Even so, if the owner and the heir keep crashing you can still create a situation when you lose the ETS data. So if its mission critical, serialising the ETS data periodically (at some appropriate “save point”) may still make sense.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement