If you want good answers, you might wish to take the
advice offered here.
in reply to bulletin board
Aside from that, at a glance, you don't use strict, you
are using cgi-lib.pl rather than CGI, your temp
file handling has a ton of race conditions, your lock file
handling means that if anything went wrong it would tend
to randomly fall over.
I don't know what specifically causes the (unspecified)
symptoms that lead you to post, nor do I feel inclined
to dig into it deeply enough to figure that out...