Page MenuHomePhabricator

Beta cluster fails to update database due to MigrateActorsAF maintenance script
Closed, ResolvedPublic

Description

The beta-update-databases-eqiad job started failing on June 10th , the last good build triggered at 13:20:00 UTC, and the next one failed around 14:20 UTC.

The issue is certainly due to https://gerrit.wikimedia.org/r/c/mediawiki/extensions/AbuseFilter/+/1039564 which got merged at 13:27 UTC. The patch is for T188180 by @matej_suchanek

...have afh_actor field in abuse_filter_history table.
Running /srv/mediawiki-staging/php-master/extensions/AbuseFilter/includes/Hooks/Handlers/../../../maintenance/MigrateActorsAF.php...
Beginning migration of abuse_filter.af_user and abuse_filter.af_user_text to abuse_filter.af_actor
User name "Meno25" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

User name "Ciphers" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

User name "Antime" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

User name "AhmadSherif" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

User name "شرف الدين" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

... af_id=48
Completed migration, updated 0 row(s) with 0 new actor(s), 41 error(s)
Beginning migration of abuse_filter_history.afh_user and abuse_filter_history.afh_user_text to abuse_filter_history.afh_actor
Completed migration, updated 0 row(s) with 0 new actor(s), 0 error(s)
RuntimeException from line 1113 of /srv/mediawiki-staging/php-master/includes/installer/DatabaseUpdater.php: Execution of /srv/mediawiki-staging/php-master/extensions/AbuseFilter/includes/Hooks/Handlers/../../../maintenance/MigrateActorsAF.php did not complete successfully.
#0 /srv/mediawiki-staging/php-master/includes/installer/DatabaseUpdater.php(606): MediaWiki\Installer\DatabaseUpdater->runMaintenance('MediaWiki\\Exten...', '/srv/mediawiki-...')
#1 /srv/mediawiki-staging/php-master/includes/installer/DatabaseUpdater.php(563): MediaWiki\Installer\DatabaseUpdater->runUpdates(Array, true)
#2 /srv/mediawiki-staging/php-master/maintenance/update.php(189): MediaWiki\Installer\DatabaseUpdater->doUpdates(Array)
#3 /srv/mediawiki-staging/php-master/maintenance/includes/MaintenanceRunner.php(696): UpdateMediaWiki->execute()
#4 /srv/mediawiki-staging/php-master/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#5 /srv/mediawiki-staging/multiversion/MWScript.php(158): require_once('/srv/mediawiki-...')
#6 {main}

Event Timeline

User name "Meno25" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.

MariaDB [arwiki]> select * from actor where actor_name = 'Meno25';
+----------+------------+------------+
| actor_id | actor_user | actor_name |
+----------+------------+------------+
|       70 |         72 | Meno25     |
+----------+------------+------------+
1 row in set (0.001 sec)

MariaDB [arwiki]> select af_user from abuse_filter where af_user_text = 'Meno25' limit 5;
+---------+
| af_user |
+---------+
|   13647 |
|   13647 |
|   13647 |
|   13647 |
|   13647 |
+---------+
5 rows in set (0.001 sec)

Data there is clearly corrupted (via import?)

Ran this:

MariaDB [arwiki]> update abuse_filter set af_user = 72, af_actor = 70 where af_user_text = 'Meno25';
Query OK, 17 rows affected (0.018 sec)
Rows matched: 17  Changed: 17  Warnings: 0

let's see what's next

I did some magic that involved doing stuff like this:

$user = \MediaWiki\MediaWikiServices::getInstance()->getUserFactory()->newFromName( 'Antime' );
\MediaWiki\MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser( $user, \MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_MAINT, false );
\MediaWiki\MediaWikiServices::getInstance()->getActorStore()->acquireActorId( $user, wfGetDB( DB_PRIMARY ) );

It now passes arwiki. Don't know if other wikis are broken too. Will see. I'll wait for the scap to kick in.

Now commonswiki is broken. I hope we didn't import too many abuse filters from production.

For commonswiki:

Running /srv/mediawiki-staging/php-master/extensions/AbuseFilter/includes/Hooks/Handlers/../../../maintenance/MigrateActorsAF.php...
Beginning migration of abuse_filter.af_user and abuse_filter.af_user_text to abuse_filter.af_actor
User name "DieBuche" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Mike.lifeguard" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Kanonkas" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Rocket000" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Kwj2772" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Meno25" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "The Evil IP address" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Krinkle" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
User name "Rillke" is usable, cannot create an anonymous actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this situation.
... af_id=83
Completed migration, updated 0 row(s) with 0 new actor(s), 22 error(s)
Beginning migration of abuse_filter_history.afh_user and abuse_filter_history.afh_user_text to abuse_filter_history.afh_actor
Completed migration, updated 0 row(s) with 0 new actor(s), 0 error(s)

Fixed commons. Let's see what's next.

I'm still super confused, but I think the corruptions might be related to RenameUser. AbuseFilter did not support RenameUser until 65708afcea842c696726883ab3c13f75cf5066bb, so old af(h)_user_text are still in the database. Maybe the maintenance script is complaining because of this? Also, if there was a database import, the renamed users wouldn't propagate from prod to beta, right?

I think it's because it was imported from production. While the users were not imported. You can see the user id stored in af table is the production user.

Fixed commons. Let's see what's next.

enwiki >:(

It had 31 case. I fixed it via stuff like:

$users = ['Prodego', 'Tim1357', 'Ruslik0', 'Mr.Z-man', '28bytes', 'Reaper Eternal', 'NawlinWiki', 'Beetstra', 'Shirik', 'Kww', 'Mindmatrix', 'Feezo', 'Hersfold', 'Cenarium', 'The Earwig', 'PeterSymonds', 'Xeno', 'EdoDodo', 'NuclearWarfare', 'Od Mishehu', 'Someguy1221', 'Soap', 'Nakon', 'Maxim', 'Gogo Dodo', 'Martijn Hoekstra'];
foreach ( $users as $userName ) {
    $user = \MediaWiki\MediaWikiServices::getInstance()->getUserFactory()->newFromName( $userName );
    var_dump( $userName);
    if ( $user ) {
        \MediaWiki\MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser( $user, \MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_MAINT, false );
        \MediaWiki\MediaWikiServices::getInstance()->getActorStore()->acquireActorId( $user, wfGetDB( DB_PRIMARY ) );
    }
   
}

And then:

sql enwiki --write -- -e "select * from actor order by actor_id desc limit 30;" | awk -F $'\t' '{printf "update abuse_filter set af_user = %s, af_actor = %s where af_user_text = \"%s\";\n",$2,$1,$3 }' | xargs -0 -I{} sql enwiki --write -- -e '{}'

Now it passes

Ladsgroup claimed this task.