There are many reasons we implemented while_preventing_writes
this way in particular that may not be obvious from the PR.
- Opening transactions isn’t free and can result in a lot of overhead on queries.
- Readonly transactions don’t play nice with some tools used at scale like ProxySQL.
- Both Shopify and GitHub used similar approaches in our applications to blocking writes on reading connections and we felt there was enough prior usage to justify upstreaming it.
Implementing a way to optionally use readonly transactions would be fine, but we don’t want to replace while_preventing_writes
with readonly transactions.