You could try setting the cflock to throw an error on timeout and catch
the error and make it log it somewhere for you - then you will be able to
see if that is your problem.

> Ayudh's recommendation solves my problem nicely (thanks!).
> 
> Would still be interested to know why the locking wasn't working 100
> percent, it seems a little dodgy to me, i'm sure there's an explanation
> though.
> 
> tim
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Mark Lynch
> Sent: Thursday, 6 February 2003 9:11 AM
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: cf locking
> 
> 
> I was about to suggest the method that Ayudh recommended and the only
> other comments I would have are:
> 1. Do you mean to lock the Session scope instead of the Application?
> 2. And you should only nead a ReadOnly lock.
> 3. As far as I know you should minimise the length of time that you need
> to lock variables for, i.e. Don't do any loops inside a lock or queries as
> they can lock the variables for too long.  We used to do it like this but
> because of the pain of locking issues we have changed to using the Request
> scope for holding dsn variables.  This also removes the code from your
> application.cfm where you check if the DSN exists and if it doesn't then
> you assign it.
> 
> Hope that makes sense.
> 
> Mark
> 
> > Not sure if this solves your problem, but looking at your code, why not
> let
> > SQL do the incrementing and the database will take care of concurrency for
> > you. Then you don't need to worry about any locking or CFTRANSACTION.
> > Something like this:
> >
> > <cfquery name="uAd" datasource="#session.DSN#">
> > UPDATE theTable
> > SET clicks = clicks + 1
> > WHERE ID=1
> > </cfquery>
> >
> > Regards: Ayudh
> >
> > +--------------------------------------------------------------+
> > | Turn on your Revenue Stream...                               |
> > | Bolt on a Virtual Cash Register to your e-commerce site now. |
> > | VeriPay from Xilo Online: http://www.xilo.com                |
> > +--------------------------------------------------------------+
> > ----- Original Message -----
> > From: "Tim Rox" <[EMAIL PROTECTED]>
> > To: "CFAussie Mailing List" <[EMAIL PROTECTED]>
> > Sent: Wednesday, February 05, 2003 17:18
> > Subject: [cfaussie] cf locking
> >
> >
> > > Hello all,
> > >
> > > Am currently trying to track the number of times a page is accessed by
> > > incrementing a field in my database.
> > >
> > > I thought i would check that it was counting correctly for many
> concurrent
> > > users by using a loop with 50 http requests for my page. I ran this page
> > > through two browsers simultaneously.
> > >
> > > Even though i have a lock with the scope "application" around my code
> for
> > > incrementing, i still get values of around 90-100 at the end of
> requesting
> > > the page 100 times (50 requests x 2 browsers).
> > >
> > > I shouldn't really be getting concurrency problems if i have an
> > > application-level lock should I?
> > >
> > > the code looks something like:
> > >
> > > <cflock timeout="1000" throwontimeout="No" scope="APPLICATION"
> > > type="EXCLUSIVE">
> > > <cftransaction>
> > > <cfquery name="qAd" datasource="#session.DSN#">
> > > SELECT clicks
> > > FROM theTable
> > > WHERE ID=1
> > > </cfquery>
> > > <cfset incrementclicks=qAd.clicks+1>
> > > <cfquery name="uAd" datasource="#session.DSN#">
> > > UPDATE theTable
> > > SET clicks=#incrementclicks#
> > > WHERE ID=1
> > > </cfquery>
> > > </cftransaction>
> > > </cflock>
> > >
> > >
> > >
> > > -----------------------
> > >
> > > Tim Roxburgh
> > > Newgency Pty Ltd
> > > 2a Broughton St
> > > Paddington 2021
> > > Sydney, Australia
> > > Ph (02) 9331 2133
> > > Fax (02) 9331 5199
> > > http://www.newgency.com/index.cfm?referer=rysig
> > >
> > >
> > > ---
> > > You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> > > To unsubscribe send a blank email to
> > [EMAIL PROTECTED]
> > >
> > > MX Downunder AsiaPac DevCon - http://mxdu.com/
> 
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
> [EMAIL PROTECTED]
> 
> MX Downunder AsiaPac DevCon - http://mxdu.com/

---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to