I was reading about the
while_preventing_writes API that was added to Rails 6 in this PR. I’m trying to understand why it was preferred over read-only database transactions, which are supported by both PostgreSQL and MySQL.
I noticed that the
while_preventing_writes functionality added a nontrivial amount of internal complexity (e.g. adapters need to handle it), and it seems to me it would be both simpler and more reliable to support an additional
:read_only option on the
transaction method to set
READ ONLY access mode when transaction is opened. I noticed Matthew also asked about utilizing read-only transactions in the PR.