Cfthread in Lucee and ACF

Hello!

I’m running an application that makes heavy use of cfthread to improve performance.
However I found some issues, which I could nail down to a testcase.
While this testcase behaves somehow buggy on Lucee, it run fine under ACF.

I’m running Lucee 5.2.9.31 und Windows Java 8 with Caucho Resin.

Maybe someone can reproduce the problem in another setup?

This testcase consists of three files:

index.cfm:

<cfsetting requesttimeout="600000">
<cftimer  label="threads" type="outline">
    <cfoutput>
    <cfset lthreads="">
    <cfloop from="1" to="300" index="ind">

        <cfset sThreadName="testname" & ind>
        <cfthread  name="#sThreadName#" iInd="#ind#">
            <cfobject name="thread.oThreading" component="threading">
            
            <cfset thread.sOutput=thread.oThreading.httpcall(searchid=iInd)>
            <cfif isDefined("thread.sOutput")>
                <cfoutput>
                iInd: #iInd#, #thread.sOutput#<br/>

                </cfoutput>
            </cfif>
            
        </cfthread>
<!--- insert sleep here --->
        <cfset lthreads=listAppend(lthreads, sThreadName)>
    </cfloop>

    <cfthread action="join" name="#lthreads#" timeout="6000"/> 

        <cfloop from="1" to="300" index="ind">
            <cfset sThreadName="testname" & ind>
            <cfset threadname=evaluate(sThreadname)>
            <cfif isstruct(threadname)>
                #threadname.output# 
                <cfif not len(threadname.output)>
                    empty<br/>
                </cfif>
            <cfelse>
                uiui<br/>
            </cfif>

        </cfloop>    
    </cfoutput>
    done
</cftimer>

threading.cfc (you may need to adjust port in cfhttp)
<cfcomponent>

    <cffunction  name="httpcall">
        <cfargument name="searchid" required="no">

        <cfhttp method="post" url="http://#cgi.host##getdirectoryfrompath(cgi.script_name)#/requested.cfm" result="thread.httprequest" port="80">
            <cfhttpparam type="formField" name="searchid" value="#searchid#">
        </cfhttp>
        <cfif isDefined("thread.httprequest.filecontent")>
            <cfset sleep(15)>
            <cfreturn trim(thread.httprequest.filecontent)>
        <cfelse>
            <cfset thread.sMessage="error">
            <cfreturn thread.sMessage>
        </cfif>

    </cffunction>

</cfcomponent>

requested.cfm:
<cfif isdefined("form.searchid")>
    <cfset sleep(60)>
<cfoutput>#form.searchid#</cfoutput>
<cfelse>none
</cfif>

Then open the index.cfm from a browser.
I expected to not see "empty" as output, but depending on the count of the loops in index.cfm I get more and more empty results from the threads.
ACF runs smoothly, as expected. 

By adding a sleep in the comment, Lucee can handle the code as expected, but that slows down the application significantly. 

Is there a general problem in Lucee, or is this specific to my setup and maybe existing thread-limits?

Thanks in advance
Michael

How does it run with the latest 5.3.3-60RC ?

The latest Lucee 5.3.3-60 doesn’t work either.
I also tried some older 4.5, which has the same issue.

Is there a limit saying 20 threads is ok, but 700 is not?

File a bug!

Filed a bug: [LDEV-2350] - Lucee

1 Like