Merge lp:~wgrant/launchpad/bug-1475358-crash-harder into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 18024
Proposed branch: lp:~wgrant/launchpad/bug-1475358-crash-harder
Merge into: lp:launchpad
Diff against target: 13 lines (+9/-0)
1 file modified
database/schema/patch-2209-77-2.sql (+9/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1475358-crash-harder
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+293886@code.launchpad.net

Commit message

Uniquely index PackageDiff(from_source, to_source).

Description of the change

Uniquely index PackageDiff(from_source, to_source).

Package copies crash reliably on some packages due to duplicated PackageDiff rows (bug #1475358). Since model code assumes there's at most one PackageDiff for each (from_source, to_source) pair, let's enforce that in the DB schema. Copies will now crash during the race, fixable by retrying, instead of corrupting the DB and preventing any further copy attempts.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'database/schema/patch-2209-77-2.sql'
--- database/schema/patch-2209-77-2.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2209-77-2.sql 2016-05-05 12:42:04 +0000
@@ -0,0 +1,9 @@
1-- Copyright 2016 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6CREATE UNIQUE INDEX packagediff__from_source__to_source__key
7 ON packagediff(from_source, to_source);
8
9INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 77, 2);