How to fix Drupal MySQL transaction isolation level warning

Drupal Transaction isolation level warning "REPEATABLE-READ"
Drupal Transaction isolation level warning "REPEATABLE-READ"

Introduction

When setting up or running Drupal, you may encounter a warning about MySQL’s transaction isolation level. By default, MySQL uses REPEATABLE READ, but Drupal recommends READ COMMITTED to avoid deadlocks and improve data consistency.

 

Warning

Transaction isolation level
REPEATABLE-READ
The recommended level for Drupal is "READ COMMITTED". See the setting MySQL transaction isolation level page for more information.


 

Related Drupal versions: 8,9,10,11

 

The recommended transaction isolation level for Drupal sites is 'READ COMMITTED'.
The 'REPEATABLE READ' option is supported but can result in deadlocks; the other options are 'READ UNCOMMITTED' and 'SERIALIZABLE'. They are available but not supported.

Drupal will generate a warning on the Status report page (admin/reports/status) when a MySQL, MariaDB, or equivalent database is used with the transaction isolation level set to other then 'READ COMMITTED'..

 

Solution

The core of this method is to update the settings.php file. The default location for the file is sites/default/settings.php. The file is created during the installation of your Drupal site.
It's needed to find in the file the database connection array found. (is usually located at the end of the file)

 

Method to change the Drupal transaction isolation level
$databases['default']['default'] = array(
'database' => 'databasename',
'username' => 'sqlusername',
'password' => 'sqlpassword',
'host' => 'localhost',
'driver' => 'mysql',
'prefix' => '',
'port' => '3306',
'isolation_level' => 'READ COMMITTED',
);

Add new settings to Drupal database configuration array

'isolation_level' => 'READ COMMITTED'

 

Drupal Transaction isolation level set to 'READ COMMITTED'
Drupal Transaction isolation level set to 'READ COMMITTED'

 

Conclusion

By adjusting MySQL’s transaction isolation level to READ COMMITTED, you resolve Drupal’s warning and improve database reliability. This is a one-time configuration change that ensures smoother site operation.