Page MenuHomePhabricator

GrowthExperiments never deletes rows with gelr_data IS NULL
Open, Needs TriagePublic

Description

\GrowthExperiments\NewcomerTasks\MediaWikiEventIngress\PageLatestRevisionChangedIngress is supposed to clean up Add Link recommendations when a page is edited. However, it currently doesn't do that for NULL rows that represent "no link recommendation was generated". This is what happens:

  1. PageLatestRevisionChangedIngress::clearLinkRecommendationRecordForPage gets called for a edited page with a NULL row
  2. LinkRecommendationHelper::deleteLinkRecommendation checks if the recommendation exists in the DB via LinkRecommendationStore::getByPageId(), and if it does, it deletes the row via LinkRecommendationStore::deleteByPageIds().
  3. LinkRecommendationStore::getByPageId() uses getByCondition(), which runs SELECT gelr_page, gelr_revision, gelr_data FROM growthexperiments_link_recommendations WHERE gelr_data IS NOT NULL AND $condition
  4. NULL rows don't meet the first condition, and thus are treated as missing recommendation, and the deletion never goes through.

Thoughts:

  • The check for existence is saving us primary DB writes (which are a sparse – and unscalable – resource). Some places are sure a recommendation exists beforehand (such as RevalidateLinkRecommendations::regenerateRecommendation), others (like the domain event handler) are a maybe. If all callers were sure beforehand, the check could be dropped, but otherwise, it is saving the primary DB from writes that might not be needed.
  • Null rows are not cleaned by any other mechanism (such as FixLinkRecommendationData). The only mechanism is RevalidateLinkRecommendations with --deleteNullRecommendations, but that is extremely rare to run (and it is much more eager than we'd need it to).

Event Timeline

Restricted Application added a subscriber: • Aklapper. · View Herald Transcript

@Michael: As the author of the NULL rows system, I'm curious if you have any thoughts on this. Noticed this while verifying T434319's completeness.

@Michael: As the author of the NULL rows system, I'm curious if you have any thoughts on this. Noticed this while verifying T434319's completeness.

This has been worked on one and a half years ago. If I understand it correctly, then that was introduced in [refactor(AddLink): ignore rows with null in Store](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GrowthExperiments/+/1118509).

This was seemingly done so that existing code that uses that logic is not confused by a null being present. I'm not sure if we meant to revert this change again? The commit message could be interpreted that way.

Maybe we want a more specific method, getByPageIdForDeletion? But it has been too long that I looked into it.