[thesite] CF error on home page

jeff jeff at members.evolt.org
Thu Dec 21 05:35:44 CST 2000


<ol>,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Oliver Lineham
:
: what is your opinion on using the server's
: automatic lock checking?
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

my official opinion is that using automatic lock checking is the wrong
solution to the problem.

automatic lock checking is a problem because it's something that's performed
server wide.  it wouldn't be an issue if we were on our own server, but
because we are, automatic lock checking isn't an option at all.  the problem
with it in a shared environment is that it could potentially throw errors in
other applications on the server that aren't locking or using named locks
instead of scoped locks.  automatic lock checking is also a performance hit.

my personal feeling about automatic lock checking is that it breeds lazy
programmers.  it always going to be more appropriate and more efficient to
perform the locks yourself.  that being said getting definitive information
about how to correctly lock reads and writes of session and application
scoped variables is difficult.

Allaire Documentation (case in point):

CFLOCK
CFML Language Reference
http://localhost/cfdocs/CFML_Language_Reference/2_ColdFusion_Tags/lr2_058.ht
m

I did find some other information in my searching though.

Allaire KB 14165
Changes to CFLOCK in CF server 4.5
http://www.allaire.com/Handlers/index.cfm?ID=14165&Method=Full

Allaire KB 8627
ColdFusion Performance Debugging
http://www.allaire.com/Handlers/index.cfm?ID=8627&Method=Full

Ben Forta - CFDJ
Lock It or Lose It
http://www.sys-con.com/coldfusion/archives/0208/Forta/

compared to some sites we're actually using application scoped variables
very little.  there's only 4 templates throughout the site that actually use
this scope and then only once to write (the dangerous one) and only then to
do it at the first request since the application timed out or was reissued
from a server restart.  the other 3 templates are doing reads only.

the write looks like this:

<cfparam name="application.topics" default="">

<cfif NOT IsQuery(application.topics)>
  <cfquery name="application.topics" datasource="#data#">
    SELECT categoryid, category
    FROM categorys
    WHERE
      active = 1
    ORDER BY category
  </cfquery>
</cfif>

done correctly it should look like this:

<cflock timeout="30" throwontimeout="no" type="exclusive"
scope="application">
  <cfparam name="application.topics" default="">

  <cfif NOT IsQuery(application.topics)>
    <cfquery name="application.topics" datasource="#data#">
      SELECT categoryid, category
      FROM categorys
      WHERE
        active = 1
      ORDER BY category
    </cfquery>
  </cfif>
</cflock>

similarly, the dropdown menu for topics (cent[er|re]s, categories, whatever
you wanna call them) performs a read to populate the options.

<cfoutput query="application.topics">
    <option
      value="#categoryid#"
    <cfif categoryid EQ ListFirst(url.params) OR categoryid EQ url.tid>
      selected
    </cfif>
    >&nbsp;&nbsp;- #category#</option>
</cfoutput>

done correctly, with a read-only lock, that would look like this:

<cflock timeout="30" throwontimeout="no"
  type="readonly" scope="application">
  <cfoutput query="application.topics">
      <option
        value="#categoryid#"
      <cfif categoryid EQ ListFirst(url.params) OR categoryid EQ url.tid>
        selected
      </cfif>
      >&nbsp;&nbsp;- #category#</option>
  </cfoutput>
</cflock>

the real problem however is with session variables.  these are used
throughout the site to affect the display depending on whether or not you're
logged in and based on your privileges.  it will take considerable time to
go through and address this issue.  fortunately, like the application scoped
variables that are being used, the session scope is only written to in only
a few places compared to being read all over the place.

i hope this clarifies the issue of when and how to use cflock.

btw, in case you're wondering, i did make sure that the application scoped
variables are locked properly on thesite, i didn't just use them as an
example.

thanks,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thesite mailing list