Skip to content

Bug 2085398 - Read flag changes from flag_activity and stop writing them to bugs_activity - #2796

Open
Xzzz wants to merge 6 commits into
mozilla:masterfrom
Xzzz:bug-2085398
Open

Xzzz wants to merge 6 commits into
mozilla:masterfrom
Xzzz:bug-2085398

Conversation

@Xzzz

@Xzzz Xzzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Makes flag_activity the only record of flag changes: they are no longer written to bugs_activity, and bug history, bugmail and the BugModal activity stream read them from flag_activity.

Part 2 of 1806896, whose part 1 (#2657) moved flag_state_activity to core as flag_activity and writes every flag change to both tables.

Changes

  • Bugzilla::Bug and Bugzilla::Attachment no longer log flagtypes.name to bugs_activity, the user merge in editusers.cgi writes its flag changes to flag_activity.
  • GetBugActivity and BugMail's _get_diffs build the flag rows from flag_activity (previous state taken from the same flag's prior row) and ignore the old flagtypes.name rows in bugs_activity.
  • The BugModal activity stream finds a flag's last change by its flag_id in flag_activity instead of matching the flag type name.
  • New scripts/flag_activity_backfill.pl: copies the flag changes in bugs_activity that are missing from flag_activity. Before part 1, only review, feedback, needinfo and data-review were recorded there. Backfilled rows have flag_id 0, as the flag can't be recovered reliably from bugs_activity, their history entries show the new state without the previous one. Runs in batches of 1000 bugs, one transaction each, and skips rows already present, so it can be re-run.
  • New t/flag-activity-backfill.t

The old flagtypes.name rows stay in bugs_activity, nothing is deleted.

Deploy steps

Without the backfill, history before part 1 loses its changes to flag types other than review, feedback, needinfo and data-review. The script is safe while the current code still writes both tables, so it can run before the switch:

  1. From the new image, before the rollout: perl scripts/flag_activity_backfill.pl --dry-run, check the counts (unknown flag type counts changes to flag types deleted or renamed since; those are skipped).
  2. Same command without --dry-run.
  3. Roll out.
  4. Optional: run the script again; it should insert 0 rows.

If it can only run after the rollout, run steps 1-2 right after it; until then those older changes are missing from bug history.

Test plan

  • Set a needinfo, a review on an attachment and an approval flag, then clear one: bug history, the activity stream and the bugmail show each change with its previous state, and bugs_activity gets no new flagtypes.name row
  • On a bug with older approval flag changes only in bugs_activity: missing from history before the backfill, shown after it
  • Merge two users with pending requests in editusers.cgi: the reassigned requests appear in bug history

References

@Xzzz

Xzzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Please note that the test_sanity critic failure is the $$ on master fixed by #2795. I'll re-run CI once it's merged, it should go green, unless I missed stg ;)

@Xzzz
Xzzz requested a review from dklawren October 23, 2026 19:06

This branch has not been deployed

No deployments
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.

1 participant