Page MenuHomePhabricator

MW cannot install because MariaDB 12.x reports read_only as "OFF"
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • MariaDB 12.0.2
  • Install MediaWiki 1.43.3 via webinstaller

What happens?:
The installation page it shows this error:
/mediawiki/mw-config/index.php?page=Install Wikimedia\Rdbms\DBReadOnlyError: Database is read-only: The primary database server is running in read-only mode.

The db query: SELECT @@GLOBAL.read_only AS Value

Result:
[rdbms] (bool)$row = 1
[rdbms] $row->Value = OFF
[rdbms] (bool)$row->Value = 1

OFF is returned, which is not recognized by MW as a boolean value

What should have happened instead?:
MediaWiki should not have detected the database as being in readonly mode

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
First reported on Discord: https://discord.com/channels/178359708581625856/1404036592527741049

MariaDB docs of read only variable

documented boolean literals

yes no, 0 1 are boolean values. ON and OFF are not documented to be booleans, but are apparently used as such by the variables system.

Event Timeline

Change #1176849 had a related patch set uploaded (by TheDJ; author: Stefantalpalaru):

[mediawiki/core@master] rdbms: Fix read-only detection for MariaDB

https://gerrit.wikimedia.org/r/1176849

mariadb 12.0.2 is 3 days old, so also not inconceivable that it's a bug in the new release.

quote from another user: ""SELECT @@GLOBAL.read_only" returns "0" in mariadb-11.8.3."

Alien333 renamed this task from MW cannot install because the mariadb reports as readonly to MW cannot install because MariaDB 12.0.2 reports read_only as "OFF".Aug 11 2025, 4:58 PM

12.0.1 change, and it seems intentional so far.
Ticket id is now: https://jira.mariadb.org/browse/MDEV-37429

It's official. MariaDB 12 changed "read_only" from bool to enum:

"read_only is changed to an enum and one can use the following

names for the lock levels:

OFF, ON, NO_LOCK, NO_LOCK_NO_ADMIN"
Aklapper renamed this task from MW cannot install because MariaDB 12.0.2 reports read_only as "OFF" to MW cannot install because MariaDB 12.x reports read_only as "OFF".Aug 13 2025, 11:08 AM

Change #1176849 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1176849

Change #1178553 had a related patch set uploaded (by MacFan4000; author: Stefantalpalaru):

[mediawiki/core@REL1_44] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178553

Change #1178554 had a related patch set uploaded (by MacFan4000; author: Stefantalpalaru):

[mediawiki/core@REL1_43] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178554

Change #1178554 merged by jenkins-bot:

[mediawiki/core@REL1_43] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178554

Change #1178553 merged by jenkins-bot:

[mediawiki/core@REL1_44] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178553

Should we also backport to 1.39? /genq

would have cherry picked, but the file in question was renamed in 1.41, meaning that a cherry pick to 1.39 causes merge conflicts.

Change #1178968 had a related patch set uploaded (by A smart kitten; author: Stefantalpalaru):

[mediawiki/core@REL1_39] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178968

While testing out this patch locally, it struck me that part of the installer's current behaviour seems potentially slightly weird (or maybe there's something I'm misunderstanding?) -- the [web/cli] installer seems to eventually end up in a code-path that calls the serverIsReadOnly() function, but seemingly only after the installation will have already failed if the database was actually set to read-only mode(?)
In testing with MediaWiki 1.44 (prior to @Stefantalpalaru's patch) & MariaDB 12 locally, the installer fails at the step "Creating main page with default content..."; however, when I actually set the DB to read-only (using SET GLOBAL READ_ONLY=ON;), a DBQueryError is thrown much earlier (at the "Setting up database..." stage).

Anyhow, that seems like a separate issue (if it is one), I just thought it was potentially worth mentioning!

Change #1178968 merged by jenkins-bot:

[mediawiki/core@REL1_39] rdbms: Fix read-only detection for MariaDB 12

https://gerrit.wikimedia.org/r/1178968

Also gonna copy this over from the MariaDB devs' response in case it's something we should consider:

Admittedly, now casting @@read_only (or any enum sysvar) to an integer doesn't work correctly and we should fix it. But it won't help MediaWiki, because they perform casting in PHP not in MariaDB. If MediaWiki would've used CAST(@@read_only AS INT) — then it would've been something we could and should fix. But because they cast in PHP, the bug must be fixed in PHP, that is, in MediaWiki. [...]

Any idea, when a bugfix will be released.

Reedy assigned this task to Stefantalpalaru.

It's which error? MediaWiki, MariaDB or PHP?

在T401570#11210943中,@Tunglinwu写道:

It's which error? MediaWiki, MariaDB or PHP?

It's more like that the upstream (MariaDB) changed their ways to work, message of which didn't go to MediaWiki, so downstream (MediaWiki) now knowing this should follow up; rather than "anyone did something wrong".

The result would be that if you want to use newer versions of MariaDB (so 12+) with MediaWiki 1.44-, you should apply a patch. Base patch link is here; see the "cherry picks" on the right side to choose the corresponding version of the patch.