Repository navigation
Conversation
…tivity row for older flags and store the cutoff
…eared, and refuse to delete a requestee kept in flag_activity
…ee's account is deleted
…urn allowuserdeletion back off
| # MySQL can't make a column of a foreign key NOT NULL. Drop the key and add | ||
| # it back right after. | ||
| $dbh->bz_drop_fk('flag_activity', 'who'); | ||
| $dbh->bz_alter_column( |
There was a problem hiding this comment.
making who NOT NULL here will likely run as ALGORITHM=COPY on prod. innodb only does NULL -> NOT NULL in place when strict sql mode is on, and Bugzilla/DB/Mysql.pm strips STRICT_TRANS_TABLES/STRICT_ALL_TABLES from every session. that copies the whole flag_activity table and blocks flag changes on live pods while it runs, the same thing the foreign_key_checks = 0 step below tries to avoid
maybe turn strict mode on for this one alter (SET SESSION sql_mode = CONCAT(@@sql_mode, ',STRICT_TRANS_TABLES')) and restore it after, or run the ddl directly with ALGORITHM=INPLACE, LOCK=NONE so it fails instead of silently copying. the backfill already fills every who, so strict mode won't trip on nulls
There was a problem hiding this comment.
Good catch, thanks! :)
Strict mode (STRICT_TRANS_TABLES) is now added to the session sql_mode only around this alter, and the original mode is restored right after (like the foreign_key_checks step).
Checked on MySQL 8.0.42 by forcing ALGORITHM=INPLACE, LOCK=NONE onto the statement: it's refused without strict mode ("cannot silently convert NULL values [...] Try ALGORITHM=COPY") and goes through with it.
Fixed in b0f4c33
Summary
Prepares the database for #2796: makes
flag_activity.whoNOT NULL, gives every flag aflag_activityrow, and stores the time it ran as the cutoff betweenbugs_activityandflag_activity. No code reads them yet, #2796 does, once this is deployed.Changes
flag_activity.whobecomes NOT NULL. #2808 (bug 2088705) added it nullable and writes it on every change. On MySQL its foreign key is dropped for the change and added back at the end of checksetup.flag_activityrow (flags last changed beforeflag_activitylogged every type) a row with its current state, dated at its last change, in batches of 10,000 flags. It then stores the time it ran in the new one-row tableflag_activity_migration, which also keeps it from running again.set_flag_activity_cutoffinBugzilla::Test::Util, and new testt/flag-activity-start-rows.t.t/flag-activity-who.tnow checks the NOT NULL change, andt/bmo/bugmail-flag-events.tsetswhoin its rows.Deploy
The current code already writes
whoand logs every flag change to both tables, so it runs unchanged on the new schema. The backfill can take a while on production. #2796 has to be deployed in a later release.Test plan
flag_activityrow: each gets one,flag_activity_migrationholds one row, and a second run adds nothingwhosetReferences