From: "Clément Lassieur" <clement@lassieur.org>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: 32190-done@debbugs.gnu.org
Subject: bug#32190: [PATCH] database: Merge Derivations into Builds table.
Date: Thu, 16 Aug 2018 23:00:17 +0200 [thread overview]
Message-ID: <87y3d63u3i.fsf@lassieur.org> (raw)
In-Reply-To: <87h8jwvkg8.fsf@elephly.net>
Pushed, thank you for the review!
Clément
Ricardo Wurmus <rekado@elephly.net> writes:
> Hi Clément,
>
>> Fixes <https://bugs.gnu.org/32190>.
>
> Woo! Thank you for this patch.
>
>> * src/cuirass/base.scm (evaluate): Don't add jobs to the Derivations table.
>
> I see that you’ve mentioned your changes to “build-packages” in a later
> email.
>
> I have two general questions about this: why was the change from “id” to
> “rowid” necessary? And: could you please also update the documentation
> so that is reflects the changes?
>
>> diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
>> index b4b1652..7788ac9 100644
>> --- a/src/cuirass/database.scm
>> +++ b/src/cuirass/database.scm
> […]
>> (define (db-add-evaluation db eval)
>> (sqlite-exec db "\
>> INSERT INTO Evaluations (specification, commits) VALUES ("
>> @@ -384,27 +356,39 @@ string."
>> (define (db-add-build db build)
>> "Store BUILD in database DB. BUILD eventual outputs are stored
>> in the OUTPUTS table."
>> - (let* ((build-exec
>> - (sqlite-exec db "\
>> -INSERT INTO Builds (derivation, evaluation, log, status, timestamp, starttime, stoptime)\
>> - VALUES ("
>> - (assq-ref build #:derivation) ", "
>> - (assq-ref build #:eval-id) ", "
>> - (assq-ref build #:log) ", "
>> - (or (assq-ref build #:status)
>> - (build-status scheduled)) ", "
>> - (or (assq-ref build #:timestamp) 0) ", "
>> - (or (assq-ref build #:starttime) 0) ", "
>> - (or (assq-ref build #:stoptime) 0) ");"))
>> - (build-id (last-insert-rowid db)))
>> - (for-each (lambda (output)
>> - (match output
>> - ((name . path)
>> - (sqlite-exec db "\
>> -INSERT INTO Outputs (build, name, path) VALUES ("
>> - build-id ", " name ", " path ");"))))
>> - (assq-ref build #:outputs))
>> - build-id))
>> + (catch 'sqlite-error
>> + (lambda ()
>> + (sqlite-exec db "
>> +INSERT INTO Builds (derivation, evaluation, job_name, system, nix_name, log,
>> +status, timestamp, starttime, stoptime)
>> +VALUES ("
>> + (assq-ref build #:derivation) ", "
>> + (assq-ref build #:eval-id) ", "
>> + (assq-ref build #:job-name) ", "
>> + (assq-ref build #:system) ", "
>> + (assq-ref build #:nix-name) ", "
>> + (assq-ref build #:log) ", "
>> + (or (assq-ref build #:status)
>> + (build-status scheduled)) ", "
>> + (or (assq-ref build #:timestamp) 0) ", "
>> + (or (assq-ref build #:starttime) 0) ", "
>> + (or (assq-ref build #:stoptime) 0) ");")
>> + (let ((derivation (assq-ref build #:derivation)))
>> + (for-each (lambda (output)
>> + (match output
>> + ((name . path)
>> + (sqlite-exec db "\
>> +INSERT INTO Outputs (derivation, name, path) VALUES ("
>> + derivation ", " name ", " path ");"))))
>> + (assq-ref build #:outputs))
>> + derivation))
>
> This procedure is called when a build is scheduled, isn’t it? The
> docstring says “BUILD eventual outputs are stored in the OUTPUTS table.”
> – does this mean the names of the *expected* output directories are
> recorded in Outputs? They don’t exist at this point, right?
>
>> + (lambda (key who code message . rest)
>> + ;; If we get a unique-constraint-failed error, that means we have
>> + ;; already inserted the same build. That happens when several jobs
>> + ;; produce the same derivation, and we can ignore it.
>> + (if (= code SQLITE_CONSTRAINT_PRIMARYKEY)
>> + #f
>> + (apply throw key who code rest)))))
>
> Okay.
>
> Can we prevent this from happening in the first place? I feel a little
> uncomfortable about performing an operation that we expect to cause
> primary key errors regularly.
>
>> diff --git a/src/schema.sql b/src/schema.sql
>> index eb0f7e9..0452495 100644
>> --- a/src/schema.sql
>> +++ b/src/schema.sql
> […]
>> --- Builds are not in a one to one relationship with derivations in order to
>> --- keep track of non deterministic compilations.
>
> Is this comment still correct considering that the derivation is now the
> primary key of the Builds table?
>
>> CREATE TABLE Builds (
>> - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
>> - derivation TEXT NOT NULL,
>> + derivation TEXT NOT NULL PRIMARY KEY,
>> evaluation INTEGER NOT NULL,
>> + job_name TEXT NOT NULL,
>> + system TEXT NOT NULL,
>> + nix_name TEXT NOT NULL,
>> log TEXT NOT NULL,
>> status INTEGER NOT NULL,
>> timestamp INTEGER NOT NULL,
>> starttime INTEGER NOT NULL,
>> stoptime INTEGER NOT NULL,
>> - FOREIGN KEY (derivation) REFERENCES Derivations (derivation),
>> FOREIGN KEY (evaluation) REFERENCES Evaluations (id)
>> );
>
> Thanks again!
next prev parent reply other threads:[~2018-08-16 21:01 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 15:44 GSoC: Adding a web interface similar to the Hydra web interface Tatiana Sholokhova
2018-05-04 2:01 ` Maxim Cournoyer
2018-05-04 12:55 ` Ludovic Courtès
2018-05-05 10:50 ` Ricardo Wurmus
2018-05-08 7:26 ` Danny Milosavljevic
2018-05-09 9:56 ` Ricardo Wurmus
2018-05-09 17:21 ` Ricardo Wurmus
2018-05-13 18:45 ` Tatiana Sholokhova
2018-05-13 19:30 ` Gábor Boskovits
2018-05-13 19:33 ` Tonton
2018-05-13 19:54 ` Danny Milosavljevic
2018-05-14 3:34 ` Chris Marusich
2018-05-14 4:20 ` Ricardo Wurmus
2018-05-17 22:31 ` Tatiana Sholokhova
2018-05-18 20:35 ` Ricardo Wurmus
2018-05-21 21:52 ` Tatiana Sholokhova
2018-05-22 5:33 ` Ricardo Wurmus
2018-05-23 21:06 ` Tatiana Sholokhova
2018-05-24 6:03 ` Ricardo Wurmus
[not found] ` <CAMSS15DThnLO+YEVaBmJ9ozMeu4mO1rHAdXHgZ8K+Csu40pORQ@mail.gmail.com>
2018-05-28 10:39 ` Ricardo Wurmus
2018-06-02 15:03 ` Ricardo Wurmus
2018-06-03 15:50 ` Tatiana Sholokhova
2018-06-03 19:40 ` Ricardo Wurmus
2018-06-04 22:14 ` Tatiana Sholokhova
2018-06-05 20:40 ` Ricardo Wurmus
2018-06-06 18:02 ` Danny Milosavljevic
2018-06-10 14:36 ` Tatiana Sholokhova
2018-06-11 10:19 ` Ricardo Wurmus
2018-06-11 11:23 ` Ludovic Courtès
2018-06-12 16:35 ` Danny Milosavljevic
2018-06-12 21:52 ` Ricardo Wurmus
2018-06-12 22:43 ` Tatiana Sholokhova
2018-06-13 6:39 ` Gábor Boskovits
2018-06-13 8:27 ` Danny Milosavljevic
2018-06-13 13:58 ` Joshua Branson
2018-06-13 14:22 ` Gábor Boskovits
2018-06-13 15:07 ` Joshua Branson
2018-06-25 10:46 ` Gábor Boskovits
2018-06-25 12:12 ` Tatiana Sholokhova
2018-06-27 19:56 ` Ludovic Courtès
2018-07-04 20:54 ` Tatiana Sholokhova
2018-07-04 21:47 ` Jelle Licht
2018-07-05 8:27 ` Danny Milosavljevic
2018-07-06 9:58 ` Gábor Boskovits
2018-07-08 19:48 ` Tatiana Sholokhova
2018-07-08 21:09 ` Danny Milosavljevic
2018-07-29 12:01 ` Clément Lassieur
2018-07-29 13:25 ` Gábor Boskovits
2018-07-29 14:41 ` Clément Lassieur
2018-07-08 21:19 ` Gábor Boskovits
2018-07-18 10:37 ` Clément Lassieur
2018-07-19 20:10 ` Tatiana Sholokhova
2018-07-19 21:47 ` Amirouche Boubekki
2018-07-18 10:19 ` Clément Lassieur
2018-07-17 19:31 ` Clément Lassieur
2018-07-17 22:32 ` bug#32190: Cuirass doesn't check if two subsequent jobs yield the same derivation Clément Lassieur
2018-07-24 10:05 ` Ludovic Courtès
2018-08-04 16:03 ` bug#32190: [PATCH] database: Merge Derivations into Builds table Clément Lassieur
2018-08-04 16:09 ` Clément Lassieur
2018-08-08 12:13 ` Clément Lassieur
2018-08-14 16:57 ` Clément Lassieur
2018-08-14 19:04 ` Ricardo Wurmus
2018-08-15 18:57 ` Clément Lassieur
2018-08-16 21:00 ` Clément Lassieur [this message]
2018-05-29 16:07 ` GSoC: Adding a web interface similar to the Hydra web interface Ludovic Courtès
2018-05-29 16:17 ` Gábor Boskovits
2018-07-18 9:34 ` Clément Lassieur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y3d63u3i.fsf@lassieur.org \
--to=clement@lassieur.org \
--cc=32190-done@debbugs.gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.