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

Proposed by William Grant on 2016-05-05
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 2016-05-05 Approve on 2016-05-05
Review via email:

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.
Colin Watson (cjwatson) :
review: Approve

Preview Diff

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