← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/build-duration into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/build-duration into lp:launchpad.

Requested reviews:
  Robert Collins (lifeless): db
  Stuart Bishop (stub): db
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #612899 Some recipe builds have NULL date_started but non-NULL date_finished
  https://bugs.launchpad.net/bugs/612899


= Summary =
Fix bug #612899: Some recipe builds have NULL date_started but non-NULL date_finished

== Proposed fix ==
Fix the broken production data before migration by using the
date_first_dispatched (which we have determined is not broken) to synthesize a
build_duration.

Add a constraint to ensure this bug doesn't re-surface.

== Pre-implementation notes ==
Discussed with bigjools

== Implementation details ==
Some of the sampledata was broken, so I fixed it.

== Tests ==
None

== Demo and Q/A ==
None

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  database/sampledata/current.sql
  database/sampledata/current-dev.sql
  database/schema/patch-2207-75-0.sql

./database/schema/patch-2207-75-0.sql
       7: Line exceeds 78 characters.
      10: Line exceeds 78 characters.
      12: Line exceeds 78 characters.
      15: Line exceeds 78 characters.
      18: Line exceeds 78 characters.
-- 
https://code.launchpad.net/~abentley/launchpad/build-duration/+merge/31655
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/build-duration into lp:launchpad.
=== modified file 'database/sampledata/current-dev.sql'
--- database/sampledata/current-dev.sql	2010-07-30 23:01:04 +0000
+++ database/sampledata/current-dev.sql	2010-08-03 15:39:50 +0000
@@ -1,5 +1,6 @@
 -- Copyright 2010 Canonical Ltd.  This software is licensed under the
 -- GNU Affero General Public License version 3 (see the file LICENSE).
+-- Created using pg_dump (PostgreSQL) 8.4.4
 
 SET check_function_bodies = false;
 SET client_encoding = 'UTF8';
@@ -2313,7 +2314,7 @@
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (26, 1, true, '2007-07-08 00:00:00', '2007-07-07 23:58:41', '2007-07-08 00:00:01', NULL, 1, 2, 1, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (27, 1, true, '2007-07-24 00:00:00', '2007-07-23 23:58:41', '2007-07-24 00:00:01', NULL, 1, 1, 1, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (28, 3, true, '2007-08-10 00:00:00', '2007-08-10 00:00:00', '2007-08-10 00:00:13', NULL, 1, 1, 1, 1);
-INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (29, 1, false, '2007-08-09 21:54:18.553132', NULL, '2007-08-09 23:59:59', NULL, NULL, 1, NULL, 1);
+INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (29, 1, false, '2007-08-09 21:54:18.553132', '2007-08-09 23:49:59', '2007-08-09 23:59:59', NULL, NULL, 1, NULL, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (30, 3, false, '2007-08-10 00:00:01', '2007-08-10 00:00:01', '2007-08-10 00:00:14', NULL, 1, 1, 1, 1);
 
 
@@ -10543,6 +10544,13 @@
 ALTER TABLE structuralsubscription ENABLE TRIGGER ALL;
 
 
+ALTER TABLE suggestivepotemplate DISABLE TRIGGER ALL;
+
+
+
+ALTER TABLE suggestivepotemplate ENABLE TRIGGER ALL;
+
+
 ALTER TABLE teammembership DISABLE TRIGGER ALL;
 
 INSERT INTO teammembership (id, person, team, status, date_joined, date_expires, last_changed_by, last_change_comment, proposed_by, acknowledged_by, reviewed_by, date_proposed, date_last_changed, date_acknowledged, date_reviewed, proponent_comment, acknowledger_comment, reviewer_comment, date_created) VALUES (1, 1, 17, 3, '2005-03-03 10:02:53.830191', '2050-03-03 10:02:53.830191', NULL, NULL, 1, NULL, 1, '2005-03-03 10:02:53.830191', NULL, NULL, '2005-03-03 10:02:53.830191', NULL, NULL, NULL, '2008-02-15 13:59:16.98918');

=== modified file 'database/sampledata/current.sql'
--- database/sampledata/current.sql	2010-07-30 23:01:04 +0000
+++ database/sampledata/current.sql	2010-08-03 15:39:50 +0000
@@ -1,5 +1,6 @@
 -- Copyright 2010 Canonical Ltd.  This software is licensed under the
 -- GNU Affero General Public License version 3 (see the file LICENSE).
+-- Created using pg_dump (PostgreSQL) 8.4.4
 
 SET check_function_bodies = false;
 SET client_encoding = 'UTF8';
@@ -2270,7 +2271,7 @@
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (26, 1, true, '2007-07-08 00:00:00', '2007-07-07 23:58:41', '2007-07-08 00:00:01', NULL, 1, 2, 1, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (27, 1, true, '2007-07-24 00:00:00', '2007-07-23 23:58:41', '2007-07-24 00:00:01', NULL, 1, 1, 1, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (28, 3, true, '2007-08-10 00:00:00', '2007-08-10 00:00:00', '2007-08-10 00:00:13', NULL, 1, 1, 1, 1);
-INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (29, 1, false, '2007-08-09 21:54:18.553132', NULL, '2007-08-09 23:59:59', NULL, NULL, 1, NULL, 1);
+INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (29, 1, false, '2007-08-09 21:54:18.553132', '2007-08-09 23:49:59', '2007-08-09 23:59:59', NULL, NULL, 1, NULL, 1);
 INSERT INTO buildfarmjob (id, processor, virtualized, date_created, date_started, date_finished, date_first_dispatched, builder, status, log, job_type) VALUES (30, 3, false, '2007-08-10 00:00:01', '2007-08-10 00:00:01', '2007-08-10 00:00:14', NULL, 1, 1, 1, 1);
 
 
@@ -10413,6 +10414,13 @@
 ALTER TABLE structuralsubscription ENABLE TRIGGER ALL;
 
 
+ALTER TABLE suggestivepotemplate DISABLE TRIGGER ALL;
+
+
+
+ALTER TABLE suggestivepotemplate ENABLE TRIGGER ALL;
+
+
 ALTER TABLE teammembership DISABLE TRIGGER ALL;
 
 INSERT INTO teammembership (id, person, team, status, date_joined, date_expires, last_changed_by, last_change_comment, proposed_by, acknowledged_by, reviewed_by, date_proposed, date_last_changed, date_acknowledged, date_reviewed, proponent_comment, acknowledger_comment, reviewer_comment, date_created) VALUES (1, 1, 17, 3, '2005-03-03 10:02:53.830191', '2050-03-03 10:02:53.830191', NULL, NULL, 1, NULL, 1, '2005-03-03 10:02:53.830191', NULL, NULL, '2005-03-03 10:02:53.830191', NULL, NULL, NULL, '2008-02-15 13:59:16.98918');

=== modified file 'database/schema/patch-2207-75-0.sql'
--- database/schema/patch-2207-75-0.sql	2010-07-30 10:08:40 +0000
+++ database/schema/patch-2207-75-0.sql	2010-08-03 15:39:50 +0000
@@ -3,6 +3,9 @@
 
 SET client_min_messages=ERROR;
 
+-- Fix broken production data
+UPDATE SourcePackageRecipeBuild SET build_duration = date_built - date_first_dispatched WHERE build_duration is NULL;
+
 CREATE TEMPORARY TABLE NewBuildFarmJob AS SELECT
   nextval('buildfarmjob_id_seq') AS id, 1 AS processor, True AS virtualized, date_created, date_built - build_duration AS date_started, date_built AS date_finished, date_first_dispatched, builder, build_state, build_log, 3 AS job_type, id AS sprb_id FROM SourcePackageRecipeBuild;
 
@@ -29,4 +32,10 @@
   DROP COLUMN build_state, DROP COLUMN build_log, DROP COLUMN archive,
   DROP COLUMN pocket, DROP COLUMN upload_log, DROP COLUMN dependencies;
 
+
+ALTER TABLE BuildFarmJob
+  ADD CONSTRAINT end_if_start CHECK (
+    date_finished IS NULL OR date_started IS NOT NULL);
+
+
 INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 75, 0);


Follow ups