[Catalyst] Re: Have exceeded the maximum number of attempts (1000) to open temp file/dir

John Napiorkowski jjn1056 at yahoo.com
Mon Nov 4 15:51:44 GMT 2013

Wow, that does seem odd. =A0I wonder if there's some evil sharing going on =
between mod_perl processes or something...

On Monday, November 4, 2013 8:26 AM, Bill Moseley <moseley at hank.org> wrote:

On Fri, Oct 25, 2013 at 6:51 AM, Bill Moseley <moseley at hank.org> wrote:

>[ERROR] "Caught exception in engine "Error in tempfile() using /tmp/XXXXXX=
XXXX: Have exceeded the maximum number of attempts (1000) to open temp file=

I don't really see how this can be a Catalyst issue, but I can't reproduce =
it outside of Catalyst -- and outside of our production environment. =A0=A0

Can anyone think of anything else that might be going on here? =A0=A0

The template has 10 "X" that are replaced by I think 63 random ascii charac=
ters. =A0 63^10 is a huge number of random strings. =A0 File::Temp only loo=
ps when sysopen returns EEXISTS -- that is, when sysopen fails AND the erro=
r is that the file already exists.

Sure, there's 50 web processes but the odds of them all being in exact lock=
-step with calling rand() is unlikely. =A0And even if they started out that=
 way if two processes opened the exact same name at the same time one proce=
ss would just try the next random name and be done.

I have something like 26K files in /tmp, so nothing compared to 63^10. =A0 =
And each web server is only seeing about 10 request/sec.

It's just not making sense.

Again, I'm unable to replicate the problem with a simple test script that i=
s designed to clash.

I fork 50 (or more) child processes to replicate the web server processes a=
nd then in each one I do this:

=A0 =A0 =A0 =A0 # Wait until top of the second so each child procss starts =
about the same time.

=A0 =A0 =A0 =A0 my $t =3D time(); =A0# Time::HiRes
=A0 =A0 =A0 =A0 sleep( int( $t ) + 1 - $t );

=A0 =A0 =A0 =A0 for ( 1 .. 500 ) {

=A0 =A0 =A0 =A0 =A0 =A0 my $fh =3D File::Temp->new(
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TEMPLATE =3D> 'bill_XXXXX',
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DIR =3D> '/tmp',
=A0 =A0 =A0 =A0 =A0 =A0 );

=A0 =A0 =A0 =A0 }

And never see any contention.


>The File::Temp docs say:
>If you are forking many processes in parallel that are all creating
>>temporary files, you may need to reset the random number seed using
>>srand(EXPR) in each child else all the children will attempt to walk
>>through the same set of random file names and may well cause
>>themselves to give up if they exceed the number of retry attempts.
>We are running under mod_perl. =A0 Could it be as simple as the procs all =
were in sync? =A0 I'm just surprised this has not happened before. =A0 Is t=
here another explanation?
>Where would you suggest to call srand()?
>Another problem, and one I've commented on before, is that HTTP::Body does=
n't use File::Temp's unlink feature and depends on Catalyst cleaning up. =
=A0This results in orphaned files left on temp disk.
>-- =

>Bill Moseley
>moseley at hank.org =

-- =

Bill Moseley
moseley at hank.org =

List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20131104/87dcd=

More information about the Catalyst mailing list