From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iDQ4Fbx3Yl+UTwAA0tVLHw (envelope-from ) for ; Wed, 16 Sep 2020 20:38:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 2GABEbx3Yl+gQAAAB5/wlQ (envelope-from ) for ; Wed, 16 Sep 2020 20:38:20 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A0CD194050F for ; Wed, 16 Sep 2020 20:38:19 +0000 (UTC) Received: from localhost ([::1]:39830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIeC1-0005we-21 for larch@yhetil.org; Wed, 16 Sep 2020 16:38:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIeBn-0005wQ-Kh for guix-patches@gnu.org; Wed, 16 Sep 2020 16:38:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIeBm-0002nO-CV for guix-patches@gnu.org; Wed, 16 Sep 2020 16:38:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kIeBm-0003Cx-9b for guix-patches@gnu.org; Wed, 16 Sep 2020 16:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42023] [PATCH] Retry deduplication on ENOENT Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Sep 2020 20:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42023 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: fixed patch To: Caleb Ristvedt Cc: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160028864112277 (code B ref -1); Wed, 16 Sep 2020 20:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 Sep 2020 20:37:21 +0000 Received: from localhost ([127.0.0.1]:36641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIeB7-0003Bx-Hj for submit@debbugs.gnu.org; Wed, 16 Sep 2020 16:37:21 -0400 Received: from lists.gnu.org ([209.51.188.17]:34428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIeB6-0003Bq-AS for submit@debbugs.gnu.org; Wed, 16 Sep 2020 16:37:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIeB6-0005ru-29 for bug-guix@gnu.org; Wed, 16 Sep 2020 16:37:20 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48808) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIeB5-0002cb-Jp; Wed, 16 Sep 2020 16:37:19 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=40112 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kIeB5-0001jc-7K; Wed, 16 Sep 2020 16:37:19 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200623163649.32444-1-mail@cbaines.net> <87366lxwcd.fsf@gnu.org> <87v9jg4aiz.fsf@cune.org> <87eeq3vbat.fsf@gnu.org> <87tuxu2sz6.fsf@gnu.org> <87bljka234.fsf@cune.org> <877dswpweh.fsf@gnu.org> <87sgbikclv.fsf_-_@cune.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Jour de la Vertu de =?UTF-8?Q?l'Ann=C3=A9e?= 228 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 16 Sep 2020 22:37:05 +0200 In-Reply-To: <87sgbikclv.fsf_-_@cune.org> (Caleb Ristvedt's message of "Tue, 15 Sep 2020 15:29:32 -0500") Message-ID: <87k0wtlaq6.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: wbb90hoCxg80 Hi! Caleb Ristvedt skribis: [...] >> There=E2=80=99s an issue with this patch. I gave it a spin (offloading = a few >> builds) and it got stuck in a infinite loop: >> >> stat("/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0pq31b= rhrk", 0x7ffe43898cd0) =3D -1 ENOENT (Dosiero a=C5=AD dosierujo ne ekzistas) >> link("/gnu/store/83jy739bn644w3pnwgb5kwjig0kzs92f-libwps-0.4.12/lib/libw= ps-0.4.so", "/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0p= q31brhrk") =3D -1 EEXIST (Dosiero jam ekzistas) >> stat("/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0pq31b= rhrk", 0x7ffe43898cd0) =3D -1 ENOENT (Dosiero a=C5=AD dosierujo ne ekzistas) >> link("/gnu/store/83jy739bn644w3pnwgb5kwjig0kzs92f-libwps-0.4.12/lib/libw= ps-0.4.so", "/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0p= q31brhrk") =3D -1 EEXIST (Dosiero jam ekzistas) >> stat("/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0pq31b= rhrk", 0x7ffe43898cd0) =3D -1 ENOENT (Dosiero a=C5=AD dosierujo ne ekzistas) >> link("/gnu/store/83jy739bn644w3pnwgb5kwjig0kzs92f-libwps-0.4.12/lib/libw= ps-0.4.so", "/gnu/store/.links/0k63r0n3681r2gqd00blq4z5xd7cw1knv0x049p99f0p= q31brhrk") =3D -1 EEXIST (Dosiero jam ekzistas) >> > > I believe I can explain this. In 'deduplicate' we currently treat > anything that isn't a directory as a hardlinkable thing. This includes > symlinks (although it's implementation-defined whether symlinks can be > hardlinked to - we use CAN_LINK_SYMLINK to test this in > nix/libstore/optimise-store.cc). This means that at present we > unconditionally attempt to deduplicate symlinks (which happens to work > on linux). However, 'file-exists?' uses stat, not lstat, to check for > file existence. Thus, if there is a dangling symlink, 'file-exists?' > will return #f when passed it, but of course attempting to call link() > to create it will fail with EEXIST. Attached is a modified patch that > tests for file existence with lstat instead. I expect that will fix the > problem. Ah ha! > We should probably still add a test in 'deduplicate' for whether > symlinks can be hardlinked to. If GNU/Linux and GNU/Hurd support it, it=E2=80=99s unnecessary. > Tangent: I was curious why libwps-0.4.so would be a dangling symlink, > and it turns out that it's actually a relative symlink, so when > accessing it via /gnu/store/...-libwps-0.4.12/lib/libwps-0.4.so it isn't > dangling, but when accessing it via /gnu/store/.links/0k63r... it is. I see, good catch! > From 12f5848e79b0ede95babebea240264b32e39812c Mon Sep 17 00:00:00 2001 > From: Caleb Ristvedt > Date: Sat, 8 Aug 2020 11:25:57 -0500 > Subject: [PATCH] deduplication: retry on ENOENT. > > It's possible for the garbage collector to remove the "canonical" link af= ter > it's been detected as existing by 'deduplicate'. This would cause an ENO= ENT > error when replace-with-link attempts to create the temporary link. This > changes it so that it will properly handle that by retrying. > > * guix/store/deduplication.scm (replace-with-link): renamed to > canonicalize-with-link, now also handles the case where the target link > doesn't exist yet, and retries on ENOENT. Also modified to support > canonicalizing symbolic links, though it is the caller's responsibility= to > ensure that the system supports hardlinking to a symbolic link (on Linu= x it > does). > (deduplicate): modified to use canonicalize-with-link. [...] > + (lambda args > + (let ((errno (system-error-errno args))) > + (cond > + ((=3D errno ENOENT) > + ;; either SWAP-DIRECTORY has missing directory > + ;; components or TARGET was deleted - this is a > + ;; fundamental ambiguity to the errno produced by > + ;; link() > + (if (file-exists? swap-directory) > + ;; we must assume link failed because target doesn= 't > + ;; exist, so create it. Nitpick: Please capitalize sentences, add a period at the end, and write =E2=80=9C'link'=E2=80=9D instead of =E2=80=9Clink()=E2=80=9D or =E2=80=9Cli= nk=E2=80=9D for clarity. Otherwise LGTM. I think we=E2=80=99ll have to stress-test it through offloading to catch any remaining issues. Thank you! Ludo=E2=80=99.