Defect #39437 » 0002-switch-tx-isolation-level-to-READ-COMMITTED-for-MySQ.patch
config/initializers/09-mysql-tx-isolation.rb | ||
---|---|---|
1 |
# MySQL / MariaDB default to a tx isolation level of "REPEATABLE READ". This |
|
2 |
# patch sets the tx isolation level to "READ COMMITTED" for the duration of the |
|
3 |
# connection. |
|
4 |
# |
|
5 |
# Reason: Repeatable Read semantics break the current implementation of the |
|
6 |
# issue nested set model on MySQL when parallel modifications to the same tree |
|
7 |
# happen. |
|
8 |
# |
|
9 |
module Mysql2ReadCommittedIsolation |
|
10 |
private |
|
11 | ||
12 |
def configure_connection |
|
13 |
super.tap do |
|
14 |
execute("SET SESSION tx_isolation='READ-COMMITTED'") |
|
15 |
end |
|
16 |
end |
|
17 |
end |
|
18 | ||
19 |
ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend Mysql2ReadCommittedIsolation |