Prevent people being subscribed twice to the same bug

Bug #600934 reported by Björn Tillenius
30
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

Person merge code should be updated to prevent people being subscribed twice to the same bug. Once that happens, a constraint should be added to prevent this happening again.

There should be a unique constraint on (person, bug) in the BugSubscription table, so that people can't be subscribed twice. We currently have around 190 people subscribe multiple times to the same bug, and that causes a problem when migrating bug subscriptions to the new ACL table. For example, Martin Pool is subscribed twice to bug 96751.

Something like this should delete the duplicates records, while leaving one of them:

  DELETE FROM
    bugsubscription WHERE id NOT IN (
      SELECT MAX(dup.id) FROM
        bugsubscription AS dupGROUP BY dup.person, dup.bug);

(The equivalent for structural subscriptions is bug 663947.)

Related branches

Revision history for this message
Deryck Hodge (deryck) wrote :

We'll get one of the guys working on the better subscriptions/notifications story to knock this out next week when PQM reopens.

Cheers,
deryck

Changed in malone:
status: New → Triaged
importance: Undecided → High
tags: added: story-better-bug-notification
Changed in malone:
assignee: nobody → Brian Murray (brian-murray)
status: Triaged → In Progress
Changed in malone:
milestone: none → 10.08
Revision history for this message
Brian Murray (brian-murray) wrote :

Does somebody happen to know how these came about so that we can be aware of what situations might cause a problem after the constraint is added?

Revision history for this message
Björn Tillenius (bjornt) wrote : Re: [Bug 600934] Re: BugSubscription table need a constraint to prevent people being subscribed twice to the same bug

On Wed, Jul 14, 2010 at 07:52:32AM -0000, Brian Murray wrote:
> Does somebody happen to know how these came about so that we can be
> aware of what situations might cause a problem after the constraint is
> added?

No. But by adding a constraint, the next time it happens we'll get an
OOPS report, so that we will know what to fix.

Revision history for this message
Brian Murray (brian-murray) wrote : Re: BugSubscription table need a constraint to prevent people being subscribed twice to the same bug

These are happening at least in part due to the account merging process.

Error in test testMergeTwoUnvalidatedAccounts (canonical.launchpad.scripts.ftests.test_keyringtrustanalyser.TestMergeClusters)
Traceback (most recent call last):
  File "/usr/lib/python2.6/unittest.py", line 279, in run
    testMethod()
  File "/srv/buildbot/slaves/launchpad/lucid-db-devel/build/lib/canonical/launchpad/scripts/ftests/test_keyringtrustanalyser.py", line 257, in testMergeTwoUnvalidatedAccounts
    '<email address hidden>'])])
  File "/srv/buildbot/slaves/launchpad/lucid-db-devel/build/lib/lp/registry/scripts/keyringtrustanalyser.py", line 180, in mergeClusters
    _mergeOrAddEmails(personset, emailset, cluster, logger)
  File "/srv/buildbot/slaves/launchpad/lucid-db-devel/build/lib/lp/registry/scripts/keyringtrustanalyser.py", line 145, in _mergeOrAddEmails
    personset.merge(otherperson, person)
  File "/srv/buildbot/slaves/launchpad/lucid-db-devel/build/lib/lp/registry/model/person.py", line 3568, in merge
    src_tab, src_col, ref_tab, ref_col
NotImplementedError: bugsubscription.person reference to person.id is in a UNIQUE index but has not been handled

Revision history for this message
Launchpad QA Bot (lpqabot) wrote : Bug fixed by a commit
tags: added: qa-needstesting
Changed in malone:
status: In Progress → Fix Committed
tags: removed: qa-needstesting
Changed in malone:
status: Fix Committed → Won't Fix
Deryck Hodge (deryck)
Changed in malone:
milestone: 10.08 → none
Revision history for this message
Robert Collins (lifeless) wrote : Re: BugSubscription table need a constraint to prevent people being subscribed twice to the same bug

We should fix this; it causes ui problems today, and the person merge code really isn't that ugly.

Changed in malone:
status: Won't Fix → Triaged
assignee: Brian Murray (brian-murray) → nobody
Deryck Hodge (deryck)
summary: - BugSubscription table need a constraint to prevent people being
- subscribed twice to the same bug
+ Prevent people being subscribed twice to the same bug
description: updated
Changed in malone:
importance: High → Low
tags: removed: story-better-bug-notification
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is really bug 87076, but since this is being worked I restructured the duplicates.

tags: added: merge-deactivate
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.