3.10.2 (for MySQL), the following code:
Repo.transaction(fn -> Repo.query!("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED") ... end)
[error] GenServer #PID<0.659.0> terminating ** (MyXQL.Error) (1568) Transaction characteristics can't be changed while a transaction is in progress query: SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1 ...
I can workaround this by setting isolation level before opening a transaction and then changing it back afterwards. This is problematic, however, because I must make sure that previous isolation level is restored after the process is done and if the process crashes I cannot guarantee this.