Skip to content

Bug 2085398 - Make flag_activity.who NOT NULL, add a starting flag_activity row for older flags and store the cutoff - #2830

Merged
dklawren merged 13 commits into
mozilla:masterfrom
Xzzz:bug-2085398-schema
Nov 20, 2026
Merged

dklawren merged 13 commits into
mozilla:masterfrom
Xzzz:bug-2085398-schema

Conversation

@Xzzz

@Xzzz Xzzz commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Prepares the database for #2796: makes flag_activity.who NOT NULL, gives every flag a flag_activity row, and stores the time it ran as the cutoff between bugs_activity and flag_activity. No code reads them yet, #2796 does, once this is deployed.

Changes

  • flag_activity.who becomes 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.
  • checksetup gives each flag that has no flag_activity row (flags last changed before flag_activity logged 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 table flag_activity_migration, which also keeps it from running again.
  • New set_flag_activity_cutoff in Bugzilla::Test::Util, and new test t/flag-activity-start-rows.t. t/flag-activity-who.t now checks the NOT NULL change, and t/bmo/bugmail-flag-events.t sets who in its rows.

Deploy

The current code already writes who and 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

  • Run checksetup on a database with flags that have no flag_activity row: each gets one, flag_activity_migration holds one row, and a second run adds nothing
  • Set and clear a flag: it is saved, with who set

References

…tivity row for older flags and store the cutoff
Comment thread Bugzilla/Install/DB.pm Resolved
Comment thread Bugzilla/Install/DB.pm Resolved
Comment thread t/flag-activity-who.t Resolved
Comment thread t/flag-activity-start-rows.t Resolved
Comment thread Bugzilla/DB/Schema.pm Resolved
@Xzzz
Xzzz requested a review from dklawren November 17, 2026 16:27
Comment thread Bugzilla/Install/DB.pm Resolved
Comment thread editusers.cgi Resolved
Comment thread qa/t/4_test_user_delete_requestee.t Resolved
@Xzzz
Xzzz requested a review from dklawren November 18, 2026 16:02
Comment thread Bugzilla/Install/DB.pm Resolved
@Xzzz
Xzzz requested a review from dklawren November 19, 2026 16:36
Comment thread editusers.cgi Resolved
Comment thread editusers.cgi Resolved
Xzzz added 2 commits November 20, 2026 21:20
The "has made changes" warning on the delete user page also counted flag_activity rows by
who or setter_id. flag_activity has no index on setter_id, so this scanned the whole table
on every confirm page, and flag changes are already in bugs_activity while both tables are
written. Go back to counting bugs_activity only.
… request is cleared

4_test_user_delete_requestee.t now checks that deleting the requestee adds a flag_activity
row for the flag, with status ?, who the admin and no requestee.
@Xzzz
Xzzz requested a review from dklawren November 20, 2026 20:41

@dklawren dklawren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM r=dkl

@dklawren
dklawren merged commit 70f3bbb into mozilla:master Nov 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants