all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: guix-devel@gnu.org, Caleb Ristvedt <caleb.ristvedt@cune.org>
Subject: Re: 02/09: guix: store: Make register-items transactional, register drv outputs
Date: Sat, 09 Feb 2019 23:09:05 +0100	[thread overview]
Message-ID: <87wom8pqbi.fsf@gnu.org> (raw)
In-Reply-To: <20190204192243.D1BD820B84@vcs0.savannah.gnu.org> (guix-commits's message of "Mon, 4 Feb 2019 14:22:43 -0500 (EST)")

Hi reepca,

guix-commits@gnu.org skribis:

> commit 91cbfa8da90d8d1723da753c171a378dae13cb40
> Author: Caleb Ristvedt <caleb.ristvedt@cune.org>
> Date:   Wed Jan 30 17:03:38 2019 -0600
>
>     guix: store: Make register-items transactional, register drv outputs
>     
>     * guix/store/database.scm (SQLITE_BUSY, register-output-sql): new variables
>       (add-references): don't try finalizing after each use, only after all the
>       uses.
>       (call-with-transaction): New procedure.
>       (register-items): Use call-with-transaction to prevent broken intermediate
>       states from being visible. Also if item is a derivation register its
>       outputs (the C++ registering does this).
>       ((guix derivations)): use it for read-derivation-from-file and
>       derivation-path?
>     
>     * .dir-locals.el (call-with-transaction): indent it.

That looks interesting!

That’s really two changes: making a proper transaction, and registering
the outputs.  Could you make it two separate commits?

> +(define SQLITE_BUSY 5)

Please add a comment stating that this is missing in
Guile-SQLite3 0.1.0 (which we should consider fixing.)

> +(define (call-with-transaction db proc)
> +  "Starts a transaction with DB (makes as many attempts as necessary) and runs
> +PROC. If PROC exits abnormally, aborts the transaction, otherwise commits the
> +transaction after it finishes."

Please use imperative tense (“Start”, not “Starts”) and two spaces after
an end-of-sentence period.  I realize I’m nitpicking but I think that
can help make the process smoother as we go.

>  (define* (register-items items
>                           #:key prefix state-directory
>                           (deduplicate? #t)
> @@ -305,6 +336,22 @@ Write a progress report to LOG-PORT."
>      (define real-file-name
>        (string-append store-dir "/" (basename (store-info-item item))))
>  
> +    (define (register-derivation-outputs)
> +      "Register all output paths of REAL-FILE-NAME as being produced by
> +it (note this doesn't mean 'already produced by it', but rather just
> +'associated with it'). This assumes REAL-FILE-NAME is a derivation!"
> +      (let ((drv (read-derivation-from-file real-file-name))
> +            (stmt (sqlite-prepare db register-output-sql #:cache? #t)))
> +        (for-each (match-lambda
> +                    ((outid . ($ <derivation-output> path))
> +                     (sqlite-bind-arguments stmt
> +                                            #:drvpath to-register
> +                                            #:outid outid
> +                                            #:outpath path)
> +                     (sqlite-fold noop #f stmt)))
> +                  (derivation-outputs drv))
> +        (sqlite-finalize stmt)))

I don’t feel comfortable using (guix derivations) here because that’s
supposed to be a higher level of abstraction.  I don’t see any way
around it though.

Could you add a test in tests/store-database.scm for this bit?

> +        (when (derivation-path? real-file-name)
> +          (register-derivation-outputs))

For clarity I’d make it:

  (register-derivation-outputs (read-derivation-from-file real-file-name))

Otherwise LGTM.  I hope we can merge things piecemeal while preserving
existing functionality.

Could you send updated patches?

Thanks,
Ludo’.

  parent reply	other threads:[~2019-02-09 22:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190204192241.15758.66035@vcs0.savannah.gnu.org>
     [not found] ` <20190204192243.A58BA20B45@vcs0.savannah.gnu.org>
2019-02-04 23:14   ` 01/09: patches: honor NIX_STORE in site.py Ludovic Courtès
2019-02-07  0:07     ` [bug#34358] [PATCH] gnu: python@2.7: Honor NIX_STORE Caleb Ristvedt
2021-09-26  2:31       ` Sarah Morgensen
2021-09-27 16:25         ` bug#34358: " Ludovic Courtès
     [not found] ` <20190204192243.D1BD820B84@vcs0.savannah.gnu.org>
2019-02-09 22:09   ` Ludovic Courtès [this message]
2019-02-13  8:43     ` 02/09: guix: store: Make register-items transactional, register drv outputs Caleb Ristvedt
2019-03-06 13:14       ` Ludovic Courtès
2019-04-01 17:53         ` Caleb Ristvedt
2019-04-01 19:43           ` Ludovic Courtès
2019-04-04 16:20           ` Ludovic Courtès
2019-04-06 23:57             ` Caleb Ristvedt

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=87wom8pqbi.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=caleb.ristvedt@cune.org \
    --cc=guix-devel@gnu.org \
    /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.