If a milestone is deleted after an associated bug task is summarized in `BugSummaryJournal` but before the journal is rolled up using `bugsummary_rollup_journal`, the rollup process fails like this:
```
2022-05-06 00:00:39 ERROR [BugSummaryJournalRollup] Unhandled exception
Traceback (most recent call last):
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/lib/lp/scripts/garbo.py", line 2142, in run_tasks_in_thread
tunable_loop.run()
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/lib/lp/services/looptuner.py", line 391, in run
log=self.log).run()
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/lib/lp/services/looptuner.py", line 218, in run
reraise(exc_info[0], exc_info[1], tb=exc_info[2])
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/six.py", line 703, in reraise
raise value
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/lib/lp/services/looptuner.py", line 169, in run
self.operation(chunk_size)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/lib/lp/scripts/garbo.py", line 474, in __call__
noresult=True)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/store.py", line 118, in execute
return self._connection.execute(statement, params, noresult)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/databases/postgres.py", line 306, in execute
return Connection.execute(self, statement, params, noresult)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 323, in execute
raw_cursor = self.raw_execute(statement, params)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 457, in raw_execute
self._run_execution(raw_cursor, args, params, statement)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 471, in _run_execution
self._check_disconnect(raw_cursor.execute, *args)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 537, in _check_disconnect
return function(*args, **kwargs)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 187, in wrapper
return attr(*args, **kwargs)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/exceptions.py", line 185, in wrap_exceptions
six.raise_from(wrapped.with_traceback(tb), e)
File "<string>", line 3, in raise_from
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/exceptions.py", line 165, in wrap_exceptions
yield
File "/srv/launchpad.net/production/launchpad-rev-3e6ca301c25bad9ef395a0234df16d711b3dff61/env/lib/python3.5/site-packages/storm/database.py", line 187, in wrapper
return attr(*args, **kwargs)
storm.database.ForeignKeyViolation: insert or update on table "bugsummary" violates foreign key constraint "bugsummary_milestone_fkey"
DETAIL: Key (milestone)=(94619) is not present in table "milestone".
CONTEXT: SQL statement "INSERT INTO BugSummary(
count, product, productseries, distribution,
distroseries, sourcepackagename,
ociproject, ociprojectseries,
viewed_by, tag,
status, milestone, importance, has_patch, access_policy)
VALUES (
d.count, d.product, d.productseries, d.distribution,
d.distroseries, d.sourcepackagename,
d.ociproject, d.ociprojectseries,
d.viewed_by, d.tag,
d.status, d.milestone, d.importance, d.has_patch,
d.access_policy)"
PL/pgSQL function bug_summary_inc(bugsummary) line 30 at SQL statement
SQL statement "SELECT bug_summary_inc(d)"
PL/pgSQL function bugsummary_rollup_journal(integer) line 50 at PERFORM
2022-05-06 00:00:39 INFO OOPS-358b0fd081ca3e21adce6c45cdbf0834
```
This is infrequent and at present we deal with this by running `scripts/bugsummary-rebuild.py` manually, but I wonder whether we could do better. We could fix this by deleting associated `BugSummaryJournal` rows when deleting a milestone (or an OCI project or an OCI project series, both of which can also be deleted; the other FK targets can't).