rapidfsub
Just one use of “manage_relationship” makes action not able to be atomic.
I think the default value of require_atomic? should be “false”.
Why is it “true”?
Trending in Questions
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
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
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
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 14 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
rapidfsub
I am also a race condition worrying guy.
But I think many folks would write a spark dsl for “automatically setting
require_atomic? false”,because
require_atomic? trueis rare case for most apps.zachdaniel
So in a way, its supposed to be slightly annoying, and if it drives folks to understand what it means for an action to be atomic and why it matters then its doing its job
Its worth highlighting a snippet from those docs though:
zachdaniel
Writing atomic code is harder, but here is an example of a case where it will pay off significantly:
The action above raises an error about it not being atomic. In this case, the effect here is that if you ran this same update concurrently on the same record, it’s possible to have inconsistent results.
i.e with a record that has a score of 0
Action 1: record is read, current score: 0
Action 2: record is read, current score: 0
Action 1: new score is determined, new score 10
Action 2: new score is determined, new score 10
Action 1: data is written, new score 10
Action 2: data is written, new score 10
So now even though the action was called twice, and you’d expect a new score of
20, you actually have a new score of10.By using an action like this:
you now have a fully atomic update that does not have the same problems as described above
I’ve made some tweaks to the atomic update docs to potentially help with clarity. Update Actions — ash v3.29.3
rapidfsub
Thanks for your explanation and advice. I really appreciate it.
zachdaniel
require_atomic?is a safety guard. It’s like marking code as safe or unsafe in another language. It has little to no value if it defaults tofalse. It is expected that you will have to turn it off relatively often. That is still important though, as when you see that error you should consider if there is anything to be done for it.This configuration:
config :ash, :require_atomic_by_default?, false, was made only to assist with the upgrade and will be removed in the future. I would not suggest using it at all.rapidfsub
“Keep It Simple” is not “Always be simple”.
In complex problems, you can’t stay in simple.
rapidfsub
I think you are not an ash framework user.
You don’t get what “not that simple” means.
Just one use of
manage_relationshipmakes action not able to be atomic.And
manage_relationshipis a basic feature in ash,which is for creating two related resources in one action.
D4no0
When this argument is brought up, in a lot of cases it points to poor design. If you cobble code together OFC you will end up with actions that are not atomic because you are always tempted to take the easy way out and do side effects as much as possible.
Happily enough, elixir and the VM limits drastically how many shortcuts of this type you can have by making the values immutable and having a clear concurrency concept.
rapidfsub
Hmm.. Then I still cannot understand why require_atomic? defaults to true..
I think this would be the last question.
config :ash, :require_atomic_by_default?, falseIs this option “not recommended” or just “up to my choice”? @zachdaniel
I think most apps are
so most apps would use config above.
zachdaniel
It really just depends on the action. Being atomic is a property of the action. Some actions can be, some can’t be, it’s entirely based on what the action does.