Description
So there's a small issue with Sqlite where only one transaction can obtain a write lock at a time, and any attempt to write (not even commit) while another transaction has a write lock causes an error which leaves no option other than rolling back the failed transaction.
Obviously this is not how Ash expects a transaction supporting data layer to behave, which is why transactions are explicitly disabled in ash_sqlite
. Unfortunately there's not really any indication that this is the default as there's nothing in the docs that indicate that this is the case - in fact there's a couple of places that talk about using transactions.
There is reason to hope that Sqlite will get at least less surprising transaction behaviour via the BEGIN CONCURRENT
proposal, however it currently lives outside of the main tree and is not shipped by default.
Proposals:
- Doc changes that very prominently explain
ash_sqlite
's inability to run actions in a transaction. - A guide to using a reactor to replace action hooks for transaction-like behaviour.
- A verifier (in core) that explicitly warns when any action does not have
transaction? false
when the data layer does not support transacting. - A runtime check (in core) that raises an error when before or after action hooks are used with a data layer that does not support transacting.
- A verifier (in core) that verifies that the resource's data layer supports transacting when using the
before_action
andafter_action
builtin changes. - Engage with
ecto_sqlite3
andexqlite
package maintainers to try and find a better solution.
Relevant links:
BEGIN CONNCURRENT
: https://sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md- Concurrent sandbox support with begin concurrent elixir-sqlite/ecto_sqlite3#99
ecto_sqlite3
on Hex: https://hex.pm/packages/ecto_sqlite3exqlite
on Hex: https://hex.pm/packages/exqlite
Metadata
Metadata
Assignees
Labels
Type
Projects
Status