Page MenuHomePhabricator

ipblocks/block divergence in write-both mode
Closed, ResolvedPublic

Description

Beta currently has $wgBlockTargetMigrationStage = SCHEMA_COMPAT_READ_OLD | SCHEMA_COMPAT_WRITE_BOTH. @dom_walden reports that differences between the two tables have developed in some wikis.

@tstarling If an autoblock exists for an IP and I try to create a block for the same IP, it gets inserted into ipblocks but not into block/block_target. On Special:Block, I see the message The block could not be made, but no existing block was found for "<ip>". If this problem persists, please report it. even though the block is created. Also happens when creating a global block and select the option to create a local block (except I don't see the message). Let me know if you would like me to raise a separate bug.

Did the maintenance scripts run correctly on beta? I notice that en_rtlwiki has nothing in block but has 4 (non-expired) blocks in ipblocks.

On enwiki beta, there are a few rows in ipblocks that are not in block. For example, there is a block against RebeccawlqphbcvaeFiora in ipblocks but not block. They all seem to have ipb_user=0, which I assume is wrong. Perhaps leftover from the actor migration project.

In dewiki beta, there is an extra block with timestamp 2024-02-12 08:59:41, which is long after the migration script finished:

MariaDB [dewiki]> select bl_id,bl_timestamp,ipb_timestamp from ipblocks,block,block_target where ipb_id=bl_id and bl_target=bt_id and bl_id>15942;
+-------+----------------+----------------+
| bl_id | bl_timestamp   | ipb_timestamp  |
+-------+----------------+----------------+
| 15944 | 20240208072137 | 20240208072137 |
| 15947 | 20240212141929 | 20240212141929 |
| 15948 | 20240212090038 | 20240212085941 |
| 15949 | 20240212094313 | 20240212090038 |
| 15950 | 20240212094539 | 20240212094450 |
| 15951 | 20240212094703 | 20240212094620 |
| 15952 | 20240212095221 | 20240212094703 |
+-------+----------------+----------------+

I'll isolate and fix the bugs, then truncate the tables on beta and run the migration script again.

Event Timeline

Change 1002683 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] block: When inserting in write-both mode, ensure the ID remains synchronised

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

In DatabaseBlockStore::acquireTarget(), the conditions do not include bt_auto. That's a major bug and it explains Dom's report about blocking an IP that's already autoblocked, and also the missing block on beta dewiki.

Change 1002713 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] block: Include bt_auto in acquireTarget() conditions

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

Change 1002683 merged by jenkins-bot:

[mediawiki/core@master] block: When inserting in write-both mode, ensure the ID remains synchronised

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

Change 1002713 merged by jenkins-bot:

[mediawiki/core@master] block: Include bt_auto in acquireTarget() conditions

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

Mentioned in SAL (#wikimedia-releng) [2024-02-19T02:54:01Z] <TimStarling> on deployment-deploy03 truncate tables block and block_target on all beta wikis T357366

Mentioned in SAL (#wikimedia-releng) [2024-02-19T02:57:45Z] <TimStarling> on deployment-deploy03 running foreachwiki maintenance/migrateBlocks.php again (T355034, T357366)

I have not been able to find a case where the IDs in ipblocks are different from those in block.

I can also create a regular block against an IP if that IP is also autoblocked, without any issue.

I have not found any other inconsistencies.

I also ran the attached query against all the wikis on beta and found no inconsistencies (except those noted in the last paragraph of T355034#9534177).

Test environment: Mainly https://en.wikipedia.beta.wmflabs.org MediaWiki 1.42.0-alpha (1525166) 12:18, 20 February 2024.