Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: file lock u...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 1391 of 1496
Post > Topic >>

Re: file lock unnecessary?

by greg@[EMAIL PROTECTED] (Greg Jetter) Apr 25, 2007 at 09:14 AM

On Wednesday April 25 2007 8:42 am, Varj=C3=BC Tam=C3=A1s wrote:
> Dear Greg!
>
> The reason I did the test, and why I detailed the result is that I could
> not reproduce any of the nasty things which can happen without locking.
> I know that everyone suggests to use the lock, but following your
> argument the test should have had a different outcome.
>
> Any idea how to improve the test to realise potential data loss?  It
> would convince me beyond "to be on the safe side".
>
> Kanya

you example  I think features two processes accessing the same file , now 
=
a=20
typical web application  may have  2000 to 2 million processes going at
the=
=20
file at the same time ... example being some thing like a  search
engine.=20

To test  or produce  a race condition  or  over writing , put  the 
script=
=20
under a  real world load .

fork 20 or thirty instances of your script at the same time and let them 
h=
ave=20
a go at the file. then look at the results and see if  it's what you think
=
it=20
should be. bet it won't be :)


 If you are certain that  no more than 2 processes will ever  access the
fi=
le=20
then feel free to forgo file locking . I have personal seen this happen
wit=
h=20
as little as three processes accessing the same file... There is a
reason=20
everyone suggest using file locking it's because we have all "been their
an=
d=20
done that". it's a common mistake new programmers make.

ask yourself "why do Data Base programs have  row locking ? " it's the
same=
=20
thing.

Greg
=20
 




 4 Posts in Topic:
file lock unnecessary?
kanya@[EMAIL PROTECTED]   2007-04-25 16:14:40 
Re: file lock unnecessary?
greg@[EMAIL PROTECTED] (  2007-04-25 06:31:16 
Re: file lock unnecessary?
kanya@[EMAIL PROTECTED]   2007-04-25 18:42:17 
Re: file lock unnecessary?
greg@[EMAIL PROTECTED] (  2007-04-25 09:14:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 11:26:21 CST 2008.