Page MenuHomePhabricator

Rewrite donor ID ingestion mw script to support polling and batching
Closed, ResolvedPublic5 Estimated Story Points

Description

Background

After some necessary scope/architecture changes, we now have a plan for how this script will look that is slightly different than the initial versions checked into production

Due to the anticipated filesize, we have a need for initializing the script before the file is in place on the host, so we will now need to poll with a timeout until the file is ready and available on the host

Additionally, there is still a batching requirement, but now the grouping strategy is better understood - we can do group lookups by email address, but if we want to issue batch preference updates, we'll need to be grouping by the preference values themselves. That is, the script should first sort users into buckets by their donor status ID, then perform batch DB operations on them

User story

As a WMF employee (or python wrapper) running this script, I'd like to be confident I can pass in an input file with potentially millions of rows and the script will perform

Requirements

  • The script can operate safely on ~250k contacts normally, ~1m when donation volume is higher. See {T418164#11643063}
  • The script should be able to handle large CSVs e.g. 1 million rows in a way that doesn't cause problems for SRE
  • The script should be able to handle a file being copied into the container post-initialization, and should timeout if the file is not ready within a preset amount of time

BDD

  • For QA engineer to fill out

Test Steps

Check requirements in T416949: Implement the first pass of a maintenance script that supports preference updates for consenting donors have been satisfied.

Design

https://wikimedia.slack.com/archives/C07C9137QGH/p1778618400416329

Acceptance criteria

The script works and can be tested manually with a file that is in place immediately locally (large or small), as well as with the wrapper script to ensure the polling functionality is working accordingly

Communication criteria - does this need an announcement or discussion?

One day this whole project will require communication, but this specific decision is probably okay to keep localized to Slack 🤞

Rollback plan

If the script has been run in prod, we will need to do DB maintenance of some sort to clean up the affected rows. A full DB rollback seems unlikely (🤞). I think there's a script for deleting preference rows that hopefully includes the globalpreference table (🤞🤞)

Event Timeline

SToyofuku-WMF moved this task from Incoming to Needs refinement on the Reader Experience Team board.

Copying priority from T424089 that this is a spin-off of

Not sure how to handle estimation

Change #1290823 had a related patch set uploaded (by Stoyofuku-wmf; author: Stoyofuku-wmf):

[mediawiki/extensions/WikimediaCustomizations@master] Rewrite donor ID maintenance script to support polling and batching

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

This is ready for review - I seem to have run into the perennial issue of tests depending on a separate extension only being skippable, which more or less defeats the purpose of tests, but at least now the code is mergeable 🙃

I would love for us to reconsider the namespacing here as it's a bit wordy, but that can also be done in a separate follow-up patch as single-file updates are certainly atomic

Change #1292006 had a related patch set uploaded (by Stoyofuku-wmf; author: Stoyofuku-wmf):

[integration/config@master] [WikimediaCustomizations] Add a soft dependency on GlobalPreferences

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

Change #1292006 merged by jenkins-bot:

[integration/config@master] Zuul: [mediawiki/extensions/WikimediaCustomizations] Add GP dependency

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

Jdlrobson-WMF subscribed.

I've merged the patch to facilitate testing early next week.

There are two unresolved Gerrit thread that we should resolve in a follow up before moving this to sign off:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikimediaCustomizations/+/1290823/comment/05bfac47_b10e7826/

Change #1295994 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaCustomizations@master] Redact email addresses in syncDonorStatus maintenance script

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

Change #1290823 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Rewrite donor ID maintenance script to support polling and batching

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

Change #1296013 had a related patch set uploaded (by Stoyofuku-wmf; author: Stoyofuku-wmf):

[mediawiki/extensions/WikimediaCustomizations@master] Remove email address from output of donor ID script

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

Change #1295994 abandoned by Jdlrobson:

[mediawiki/extensions/WikimediaCustomizations@master] Redact email addresses in syncDonorStatus maintenance script

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

Created T427942 (with a reference to T427943), so I think the follow up tasks are handled

Change #1296013 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Remove email address from output of donor ID script

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

@SToyofuku-WMF @CDanis we just need to confirm that this can run safely on a large GB file. Chris was going to kick something off, but let's sync tomorrow on how to test this is working so we can resolve this ticket.

According to @CDanis the script is processing CSV at about 1Mbyte/sec
For 10M email addresses (about 300MByte of data) the script handled it in just under 5 minutes.  decryption time <1s.

Thanks @CDanis !