Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is default ActiveRecord isolation level for transaction

What is default isolation level for transactions in Ruby on Rails for PostgreSQL or MySQL?

active_record/connection_adapters/abstract/database_statements.rb#L173

like image 908
ProkopS Avatar asked Sep 21 '15 15:09

ProkopS


1 Answers

The documentation states:

  # If your database supports setting the isolation level for a transaction, you can set
  # it like so:
  #
  #   Post.transaction(isolation: :serializable) do
  #     # ...
  #   end

And the code is:

def transaction(requires_new: nil, isolation: nil, joinable: true)

The default value, is nil, which means whatever the default isolation level of the database you are using.

The default value for MySQL is :repeatable_read.

The default value for Postgress is :read_committed.

like image 100
Brad Werth Avatar answered Sep 27 '22 18:09

Brad Werth