What is the problem?
If the replica database is lagging and if I submit the same client hints for a revision twice, I see the exception:
Error: exception of type Wikimedia\\Rdbms\\DBQueryError: Error 1062: Duplicate entry '532-0-1662' for key 'PRIMARY'\nFunction: MediaWiki\\CheckUser\\Services\\UserAgentClientHintsManager::insertMappingRows\nQuery: INSERT INTO `cu_useragent_clienthints_map` (uachm_uach_id,uachm_reference_type,uachm_reference_id) VALUES (532,0,1662),(34,0,1662),(35,0,1662),(36,0,1662),(14,0,1662),(15,0,1662),(16,0,1662) ...
I guess this is the same as is happening in T342826 but for the other client hints table.
This bug is slightly different to T344787 and T344875 because I have only been able to reproduce it when the replica is lagged.
Steps to reproduce problem
- Setup a local wiki with replication lag (see https://www.mediawiki.org/wiki/User:DWalden_(WMF)/Simulating_database_replication_lag or T342826)
- Make an edit in Firefox
- Find out the revision ID of the edit you just made
- Run this command to make two client hints requests in a row. Replace <rev id> with the revision ID you just made:
for i in {1..2}; do curl 'http://localhost:8080/w/rest.php/checkuser/v0/useragent-clienthints/revision/<rev id>' -H 'Content-Type: application/json' --data-raw '{"architecture": "", "bitness": "129", "brands": [{"brand": "Not.A/Brand", "version": "8"}, {"brand": "Chromium", "version": "114"}], "fullVersionList": [{"brand": "Not.A/Brand", "version": "8.0.0.0"}], "mobile": false, "model": "", "platform": "Linux", "platformVersion": "5.10.0"}'; done
Expected behavior: Either a success message or Client hint mappings already exist for revision <rev id>.
Observed behavior: The above exception.
Environment
Wiki(s): MediaWiki 1.41.0-alpha (ad2734f) 06:12, 29 August 2023. CheckUser 2.5 (999417f) 13:47, 28 August 2023.