\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:
- PageLatestRevisionChangedIngress::clearLinkRecommendationRecordForPage gets called for a edited page with a NULL row
- LinkRecommendationHelper::deleteLinkRecommendation checks if the recommendation exists in the DB via LinkRecommendationStore::getByPageId(), and if it does, it deletes the row via LinkRecommendationStore::deleteByPageIds().
- 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
- 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).