Skip to main content
Participant
May 3, 2006
Question

Server locking up

  • May 3, 2006
  • 1 reply
  • 262 views
Hi all,
The following code locks up my server when there are several messages to read (works fine if theres only 10 or so). Should I be using the <CFLOCK> tag with this??
Thanks


<CFSET ThisMonth = "#DatePart('m', Now())#">
<CFSET ThisDay = "#DatePart('d', Now())#">
<CFSET ThisYear = "#DatePart('yyyy', Now())#">
<cfinclude template="Navigation.cfm">
<CFOUTPUT>Inserting Mail on #SetServerDesc#</CFOUTPUT><br>
<cfdirectory action="list" directory="c:\cfusionmx\mail\undelivr\FromWEB1" name="Files" sort="datelastmodified desc">
<CFLOOP query="Files">
<CFPARAM name="InsertCount" default="0">
<cffile action="read" file="c:\cfusionmx\mail\undelivr\fromWEB1\#Files.Name#" variable="FileRead">
<CFQUERY name="InsMail" datasource="#Request.DSN#">
Insert Into _UndelivrEmail (UE_Attributes,UE_DateLastModified,UE_Mode,UE_Name,UE_FileSize,UE_Type,UE_ServerDesc,UE_EmailBody)
Values('#Files.Attributes#','#Files.DateLastModified#','#Files.Mode#','#Files.Name#','#Files.Size#','#Files.Type#','#SetServerDesc#','#FileRead#')

</CFQUERY>
<CFSET InsertCount = "#Evaluate(InsertCount +1)#">
</CFLOOP>

    This topic has been closed for replies.

    1 reply

    May 3, 2006
    First up, get your syntax up to date

    <CFSET ThisMonth = Month( Now())>
    <CFSET ThisDay = Day(Now())>
    <CFSET ThisYear = Year(Now())>

    <cfinclude template="Navigation.cfm">
    <CFOUTPUT>Inserting Mail on #SetServerDesc#</CFOUTPUT><br>

    <cfdirectory action="list" directory="c:\cfusionmx\mail\undelivr\FromWEB1" name="Files" sort="datelastmodified desc">

    <CFLOOP query="Files">
    <CFPARAM name="InsertCount" default="0">
    <cffile action="read" file="c:\cfusionmx\mail\undelivr\fromWEB1\#Files.Name#" variable="FileRead">
    <CFQUERY name="InsMail" datasource="#Request.DSN#">
    Insert Into _UndelivrEmail(
    UE_Attributes
    ,UE_DateLastModified
    ,UE_Mode
    ,UE_Name
    ,UE_FileSize
    ,UE_Type
    ,UE_ServerDesc
    ,UE_EmailBody
    )Values(
    <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Files.Attributes#">
    ,<cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#Files.DateLastModified#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Files.Mode#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Files.Name#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Files.Size#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Files.Type#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#SetServerDesc#">
    ,<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FileRead#">
    )

    </CFQUERY>
    <CFSET InsertCount = InsertCount + 1>
    </CFLOOP>

    now..

    How many files are you looping through here: <CFLOOP query="Files">

    Next Check the server logs to see whats up. you should be able to loop through houndreds of files like that, and the insert should be near instant, so besides a few seconds wait if there are a TON of files, i can't see anything wrong ...i son't think....
    coldskoolAuthor
    Participant
    May 3, 2006
    quote:

    How many files are you looping through here: <CFLOOP query="Files">

    There are currently 1,850 files

    quote:

    Next Check the server logs to see whats up.

    The logs dont have any info because the script isnt producing any exceptions... it just seems to hang the servers processor at 100% usage and never completes...