Previously there was discussion of setting transaction isolation levels on a per-transaction basis, which turned out to have a lot of unexpected complexities:
https://github.com/elixir-ecto/ecto/issues/1460As discussed in that issue, trying to set them manually within a transaction *also* has significant problems. Which leaves us in a place where it's very hard to use transaction isolation levels with Ecto.
Rather than trying to set it per-transaction, or manually with raw SQL statement, I think the right place to set transaction isolation level is on the Repo definition. Not just because the other options didn't work, but also because I think it's a cleaner abstraction, requires less code in use, and provides me with fewer opportunities to make errors when using it.
Rather than thinking of a repo as *being* a storage backend, we just need to remember that it's one *view* of a storage backend, and it's reasonable that a single application might want different views of the same backing data, with different constraints on each default view. When I'm writing code that needs to be serializable, I want a completely serializable view of the DB, where every DB action is, by default, part of that serializable world. When I forget that it's usually a bug, and when it's not a bug, I can override it by setting another level using raw SQL. (That will continue to work for all cases where it would currently work.)
If that sounds reasonable, I'll put a PR together and we can see how it shapes up.