Steps to re-produce:
- Use MediaWiki docker - https://www.mediawiki.org/wiki/MediaWiki-Docker
- Follow the steps in https://www.mediawiki.org/wiki/MediaWiki-Docker/Configuration_recipes/Alternative_databases for mariadb with replication before running docker compose up -d
- Make an edit using a non-chromium based browser (such as Firefox).
- Make an edit using Chrome with Network tab open.
- Right click on the REST API call and copy the request as "fetch".
- Open a terminal for the "mariadb-replica" container
- Login to mysql using the user root and the password main_root_password
- Run the following (based on https://mariadb.com/kb/en/delayed-replication/):
STOP SLAVE; CHANGE MASTER TO MASTER_DELAY=3600; START SLAVE;
- Load http://localhost:8080/w/api.php?action=query&format=json&meta=siteinfo&formatversion=2&siprop=dbrepllag
- Check that "lag" is set to "3600". If it is, then your replica is lagged by 60 minutes.
- Open the console for Firefox
- Paste the "fetch" command and modify the end of the URL to use the revision ID for the edit made in the Firefox browser
To finish, follow the following commands:
- Open a terminal for the "mariadb-replica" container
- Login to mysql using the user root and the password main_root_password
- Run the following:
STOP SLAVE; CHANGE MASTER TO MASTER_DELAY=0; START SLAVE;
- Load http://localhost:8080/w/api.php?action=query&format=json&meta=siteinfo&formatversion=2&siprop=dbrepllag
- Check that "lag" is set to "0". If it is, then your replica is no longer lagged.
Because the check for existing Client Hints data rows is done on a replica DB, if this replica DB is lagged enough the replica DB could report no such Client Hints row. This means that the UserAgentClientHintsManager will attempt to insert with rows that would violate the unique constraint via the index uach_name_value. This will normally cause the insert query to fail. However, there may be rows that need inserting.
Adding the IGNORE option to the insert query should address the issue by ignoring rows that violate the unique constraint on combinations of uach_name and uach_value.