Page MenuHomePhabricator

Purge unused address rows upon address change
Closed, ResolvedPublic

Description

Acceptance criteria

  • When an address is removed from an event, and no other event is using it, delete the row from the ce_address table
  • This should be done as a DeferredUpdate

Note: existing unused rows will be purged by the script for T397270.

Event Timeline

Change #1168240 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] [WIP] Purge unused addresses

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

Change #1168240 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Purge unused addresses upon address change

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

vaughnwalters subscribed.

✅ When an address is removed from an event, and no other event is using it, delete the row from the ce_address table

row is deleted from the ce_table when the address is removed from the event:

Screen Recording 2025-07-22 at 5.02.06 PM.gif (2,550×1,275 px, 3 MB)

row is also successfully deleted from the ce_table when the event is changed to online event from "In person" or "In person and online

Screen Recording 2025-07-22 at 5.03.52 PM.gif (2,380×1,190 px, 3 MB)


❓ This should be done as a DeferredUpdate

@Daimona is there a way for me to check this AC? It is correctly deleting the row, but I am not sure how to check if it is done as a DeferredUpdate (or if this even can or needs to be tested)

❓ This should be done as a DeferredUpdate

@Daimona is there a way for me to check this AC? It is correctly deleting the row, but I am not sure how to check if it is done as a DeferredUpdate (or if this even can or needs to be tested)

Hmmm I think you should see an entry in the DeferredUpdates log channel.

❓ This should be done as a DeferredUpdate

@Daimona is there a way for me to check this AC? It is correctly deleting the row, but I am not sure how to check if it is done as a DeferredUpdate (or if this even can or needs to be tested)

Hmmm I think you should see an entry in the DeferredUpdates log channel.

I'm looking in var/log and /var/log/mediawiki on betacluster and don't see a DeferredUpdates log channel ... but maybe I am looking in the wrong place?

❓ This should be done as a DeferredUpdate

@Daimona is there a way for me to check this AC? It is correctly deleting the row, but I am not sure how to check if it is done as a DeferredUpdate (or if this even can or needs to be tested)

Hmmm I think you should see an entry in the DeferredUpdates log channel.

I'm looking in var/log and /var/log/mediawiki on betacluster and don't see a DeferredUpdates log channel ... but maybe I am looking in the wrong place?

That is indeed the wrong place, the correct one is /srv/mw-log, see https://wikitech.wikimedia.org/wiki/Logs#Beta_cluster.

❓ This should be done as a DeferredUpdate

@Daimona is there a way for me to check this AC? It is correctly deleting the row, but I am not sure how to check if it is done as a DeferredUpdate (or if this even can or needs to be tested)

Hmmm I think you should see an entry in the DeferredUpdates log channel.

I'm looking in var/log and /var/log/mediawiki on betacluster and don't see a DeferredUpdates log channel ... but maybe I am looking in the wrong place?

That is indeed the wrong place, the correct one is /srv/mw-log, see https://wikitech.wikimedia.org/wiki/Logs#Beta_cluster.

The only thing that is in the DeferredUpdate log is an exception that is thrown, and I don't think this is related:

2025-07-23 00:27:07.666076 [6faa1222884710e0b36bf60c] deployment-mwmaint03 frwiki 1.45.0-alpha DeferredUpdates ERROR: Deferred update 'MediaWiki\Deferred\MWCallableUpdate_SqlBagOStuff->garbageCollect' failed to run. {"deferred_type":"MediaWiki\\Deferred\\MWCallableUpdate_SqlBagOStuff->garbageCollect"}
[Exception Wikimedia\Rdbms\DBQueryError] (/srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php:1232) Error 1290: The MariaDB server is running with the --read-only option so it cannot execute this statement
Function: SqlBagOStuff::deleteServerObjectsExpiringBefore
Query: DELETE FROM `objectstash` WHERE keyname IN ('global:abusefilter:throttle:metawiki:75:fb0025f57cfb6dbd7d59e8b5ce2577739f314030','simplewiki:abusefilter:throttle:31:fb0025f57cfb6dbd7d59e8b5ce2577739f314030','global:abusefilter:throttle:metawiki:75:81fa5442cd62b3a69a5c855fb48d43405ff5e9e7','simplewiki:abusefilter:throttle:31:81fa5442cd62b3a69a5c855fb48d43405ff5e9e7','global:loginnotify:known:e7470vc7ie5h8kxg50otndsxpj7qrox','global:loginnotify:known:o3u73xwfj0psypkgsij8h9mz83oej22','global:loginnotify:new:e7470vc7ie5h8kxg50otndsxpj7qrox','global:loginnotify:new:o3u73xwfj0psypkgsij8h9mz83oej22','global:loginnotify:known:bt5iu4o68zrisjkrmmjzkcwuamomnpf','global:loginnotify:new:bt5iu4o68zrisjkrmmjzkcwuamomnpf')  AND (exptime < '20250722232707')

  #0 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(1216): Wikimedia\Rdbms\Database->getQueryException(string, int, string, string)
  #1 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(1190): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, int, string, string)
  #2 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(647): Wikimedia\Rdbms\Database->reportQueryError(string, int, string, string, bool)
  #3 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(1740): Wikimedia\Rdbms\Database->query(Wikimedia\Rdbms\Query, string)
  #4 /srv/mediawiki/php-master/includes/libs/rdbms/querybuilder/DeleteQueryBuilder.php(230): Wikimedia\Rdbms\Database->delete(string, array, string)
  #5 /srv/mediawiki/php-master/includes/objectcache/SqlBagOStuff.php(1568): Wikimedia\Rdbms\DeleteQueryBuilder->execute()
  #6 /srv/mediawiki/php-master/includes/objectcache/SqlBagOStuff.php(1422): SqlBagOStuff->deleteServerObjectsExpiringBefore(Wikimedia\Rdbms\DatabaseMySQL, int, int)
  #7 /srv/mediawiki/php-master/includes/deferred/MWCallableUpdate.php(52): SqlBagOStuff->{closure}(string)
  #8 /srv/mediawiki/php-master/includes/deferred/DeferredUpdates.php(459): MediaWiki\Deferred\MWCallableUpdate->doUpdate()
  #9 /srv/mediawiki/php-master/includes/deferred/DeferredUpdates.php(201): MediaWiki\Deferred\DeferredUpdates::attemptUpdate(MediaWiki\Deferred\MWCallableUpdate)
  #10 /srv/mediawiki/php-master/includes/deferred/DeferredUpdates.php(288): MediaWiki\Deferred\DeferredUpdates::run(MediaWiki\Deferred\MWCallableUpdate)
  #11 /srv/mediawiki/php-master/includes/deferred/DeferredUpdatesScope.php(243): MediaWiki\Deferred\DeferredUpdates::MediaWiki\Deferred\{closure}(MediaWiki\Deferred\MWCallableUpdate, int)
  #12 /srv/mediawiki/php-master/includes/deferred/DeferredUpdatesScope.php(172): MediaWiki\Deferred\DeferredUpdatesScope->processStageQueue(int, int, Closure)
  #13 /srv/mediawiki/php-master/includes/deferred/DeferredUpdates.php(307): MediaWiki\Deferred\DeferredUpdatesScope->processUpdates(int, Closure)
@

The only thing that is in the DeferredUpdate log is an exception that is thrown, and I don't think this is related:

That's unrelated. Maybe the logs aren't enabled in beta. You can test it locally (I just verified), or also check the source (there might be more config affecting this).

The only thing that is in the DeferredUpdate log is an exception that is thrown, and I don't think this is related:

That's unrelated. Maybe the logs aren't enabled in beta. You can test it locally (I just verified), or also check the source (there might be more config affecting this).

Okay, since I can see this in the source code and have verified that this is working correctly in T397636#11026174, I am sending this to product sign off.