Skip to content

[4.x]: db/backup locks tables while running, even on MariaDB #19191

Description

@wolispace

What happened?

Description

This bug: https://bugs.mysql.com/bug.php?id=109685
Is possibly the reason --single-transaction was removed from `craft db/backup'

But people using MariaDB are not impacted by this MySQL bug, yet the Craft code comparing versions and thinks MariaDB is, so the single-transaction is dropped from the backup.

Easy fix for anyone using MariaDB who wants to allow logging in while a backup is running is to add this into config/general.php after:
->backupOnUpdate((bool)App::env('BACKUP_ON_UPDATE'))

  ->backupCommand(function(\mikehaertl\shellcommand\Command $cmd) {
    return $cmd->addArg('--single-transaction');
  })

Steps to reproduce

  1. Strats a backup craft db/backup
  2. Try to log in

Expected behavior

  1. Login completes almost as instantly as if no backup were running.

Actual behavior

  1. Login is delayed until backup finished (20mins later in our case on production!)

Craft CMS version

Craft Pro 4.18.0.1

PHP version

8.2.31

Operating system and version

Debian

Database type and version

MariaDB 10.11.15

Image driver and version

No response

Installed plugins and versions

-This may only be useful to a few people, but if they are alt lease we know a work-around, and if Craft can be modify to allow MariaDB to run with --single-transaction that would be excellent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions