proposed improvement to temp file names used by scons cache
Raven Kopelman <[email protected]> Mon, 31 Aug 2020 12:06:15 -0700
| Newsgroups | gmane.comp.programming.tools.scons.devel |
|---|---|
| Message-ID | <CAHoKKaq0ZwruQw=jLkw1CbVQrXEV=VsirF6t9PLtjkqEqZv10g@mail.gmail.com> |
--===============4259438200599941458==
Content-Type: multipart/alternative; boundary="0000000000006bd44205ae31197a"
--0000000000006bd44205ae31197a
Content-Type: text/plain; charset="UTF-8"
Hi there,
We have a CI build framework configured such that many machines are
concurrently building and sharing a scons cache. This cache lives on an
Amazon EFS filesystem, mounted as NFS.
In general this has been spectacularly successful, but every once in a
while corrupted files start coming out of the cache. Our theory is that
the EFS + NFS locking guarantees aren't good enough for the SCons temp name
collision detection algorithm - attached is a patch we are going to try
running with to see if it improves things.
In addition to hoping a formalized version of this will be considered for
SCons, I'm curious if anyone sees a more likely explanation for the
symptoms described above.
--- CacheDir.py 2020-08-19 12:59:25.790302000 -0700
+++ CacheDir.py.uuid 2020-08-19 14:00:29.693749695 -0700
@@ -32,6 +32,7 @@
import os
import stat
import sys
+import uuid
import SCons.Action
import SCons.Warnings
@@ -100,7 +101,11 @@
cd.CacheDebug('CachePush(%s): pushing to %s\n', t, cachefile)
- tempfile = cachefile+'.tmp'+str(os.getpid())
+ # UUID in case filesystem doesn't support file operations well enough
to deal with multiple
+ # machines sharing a cache and attempting to write the same file at
the same time (NFS mount of
+ # AWS EFS?).
+ # TODO: Long filename concern on Windows?
+ tempfile = cachefile+'.tmp'+str(os.getpid()) + '_' + str(uuid.uuid1())
errfmt = "Unable to copy %s to cache. Cache file is %s"
if not fs.isdir(cachedir):
Cheers,
--
*Raven Kopelman* | Team Lead, Senior Developer
Safe Software Inc.
*T* 604.501.9985 x 331 | *F* 604.501.9965
[email protected] | www.safe.com
<http://www.safe.com/emailsignature>
--0000000000006bd44205ae31197a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Hi there,</div><div><br></div><div>We have a CI build=
framework=20
configured such that many machines are concurrently building and sharing
a scons cache.=C2=A0 This cache lives on an Amazon EFS filesystem, mounted=
=20
as NFS.</div><div><br></div><div>In general this has been spectacularly=20
successful, but every once in a while corrupted files start coming out=20
of the cache.=C2=A0 Our theory is that the EFS + NFS locking guarantees=20
aren't good enough for the SCons temp name collision detection algorith=
m
- attached is a patch we are going to try running with to see if it=20
improves things.</div><div><br></div><div>In addition to hoping a=20
formalized version of this will be considered for SCons, I'm curious if=
=20
anyone sees a more likely explanation for the symptoms described above.</di=
v><div><br></div><div>--- CacheDir.py 2020-08-19 12:59:25.790302000 -0700<b=
r>+++ CacheDir.py.uuid 2020-08-19 14:00:29.693749695 -0700<br>@@ -32,6 +32,=
7 @@<br>=C2=A0import os<br>=C2=A0import stat<br>=C2=A0import sys<br>+import=
uuid<br><br>=C2=A0import SCons.Action<br>=C2=A0import SCons.Warnings<br>@@=
-100,7 +101,11 @@<br><br>=C2=A0 =C2=A0 =C2=A0cd.CacheDebug('CachePush(=
%s): =C2=A0pushing to %s\n', t, cachefile)<br><br>- =C2=A0 =C2=A0tempfi=
le =3D cachefile+'.tmp'+str(os.getpid())<br>+ =C2=A0 =C2=A0# UUID i=
n case filesystem doesn't support file operations well enough to deal w=
ith multiple<br>+ =C2=A0 =C2=A0# machines sharing a cache and attempting to=
write the same file at the same time (NFS mount of<br>+ =C2=A0 =C2=A0# AWS=
EFS?).<br>+ =C2=A0 =C2=A0# TODO: Long filename concern on Windows?<br>+ =
=C2=A0 =C2=A0tempfile =3D cachefile+'.tmp'+str(os.getpid()) + '=
_' + str(uuid.uuid1())<br>=C2=A0 =C2=A0 =C2=A0errfmt =3D "Unable t=
o copy %s to cache. Cache file is %s"<br><br>=C2=A0 =C2=A0 =C2=A0if no=
t fs.isdir(cachedir):</div><div><br></div><div>Cheers,</div><div><div dir=
=3D"ltr" class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div =
dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"lt=
r"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><=
div dir=3D"ltr"><div><div dir=3D"ltr">--<br><b>Raven Kopelman</b> | Team Le=
ad, Senior Developer<br><br><div dir=3D"ltr">Safe Software Inc.</div><b>T</=
b> 604.501.9985 x 331 | <b>F</b> 604.501.9965</div><div dir=3D"ltr"><a href=
=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
om</a> | <a href=3D"http://www.safe.com" target=3D"_blank">www.safe.com</a>=
</div><div dir=3D"ltr"><div><br></div><div><div><a href=3D"http://www.safe.=
com/emailsignature" target=3D"_blank"><img src=3D"http://cdn.safe.com/email=
signature.jpg"></a><br></div></div></div></div></div></div></div></div></di=
v></div></div></div></div></div></div></div></div></div></div></div></div><=
/div>
--0000000000006bd44205ae31197a--
--===============4259438200599941458==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Scons-dev mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/scons-dev
--===============4259438200599941458==--