2
votes

I have a ColdFusion event gateway that sometimes produces an error on the following line (where Local.curThread is a digit 1-5):

<cflock name="eventCachedQueryUpdate_thread_#Local.curThread#" timeout="0" throwontimeout="no">

The error is:

Message: timeout value is negative
Type: java.lang.IllegalArgumentException

Here's a StackTrace:

java.lang.IllegalArgumentException: timeout value is negative at java.lang.Object.wait(Native Method) at coldfusion.runtime.RWLock.waitForLock(RWLock.java:154) at coldfusion.runtime.RWLock.requestWriteLock(RWLock.java:124) at coldfusion.runtime.RWLock.requestLock(RWLock.java:46) at coldfusion.runtime.LockManager.requestNamedLock(LockManager.java:73) at coldfusion.tagext.lang.LockTag.doStartTag(LockTag.java:186) at cfeventCachedQueryUpdate2ecfc749015300$funcONINCOMINGMESSAGE.runFunction(D:\Applications\CFusion\CustomTags\4C\eventCachedQueryUpdate.cfc:21) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:437) at coldfusion.filter.EventComponentFilter.invoke(EventComponentFilter.java:67) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:399) at coldfusion.filter.EventRequestMonitorFilter.invoke(EventRequestMonitorFilter.java:47) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.eventgateway.EventProxy.invokeComponent(EventProxy.java:66) at coldfusion.eventgateway.EventProxy.invokeComponent(EventProxy.java:47) at coldfusion.eventgateway.EventRequestHandler.invokeCFC(EventRequestHandler.java:185) at coldfusion.eventgateway.EventRequestHandler.processRequest(EventRequestHandler.java:111) at coldfusion.eventgateway.EventRequestDispatcher$Task.run(EventRequestDispatcher.java:122) at coldfusion.util.SimpleWorkerThread.run(SimpleThreadPool.java:210)

Since the timeout attribute of cflock is always 0 I don't see how that could be resulting in a negative timeout value. Any ideas what's causing this and how to prevent it? Is this a bug in cflock?

I'm running Adobe ColdFusion 9.0.1.274733 Enterprise on Windows Server 2008 R2 with Java 1.6.0_17.

1
I do not have an answer, but it does not seem like the error is referring to the value you supplied. Rather an internal number the CF server generates (using your value) somewhere in the RWLock class according to the stack trace. If the error is to be believed, that number is negative, which causes the exception when CF invokes Object.wait(...). - Leigh
Leigh, that was my same thought too... which would indicate some sort of CF bug. - Richard Davies
I would dwell less on whether it's a CF bug, and more on how to make your code work. Even if the conclusion is that it's a bug... that's not gonna magically make your code not error. - Adam Cameron
I would dwell less on whether it's a CF bug Agreed. I mentioned it so as to keep that possibility the back of your mind when figuring out how you might fix the error. ie You might have to work around a bug, rather than fix a code/logic error. That does not really help solve the problem, but might point to the right approach in tackling it. - Leigh

1 Answers

0
votes

If I had to guess, it would be that event gateway requests handle the way timeout="0" incorrectly. The docs for <cflock> for ColdFusion 9 say this:

If you set timout="0", the timeout is determined by the "Timeout Requests after x" setting in the ColdFusion Administrator Settings page, if that setting is enabled. However, if the setting is not enabled, and you set timeout="0", ColdFusion can wait indefinitely to obtain the lock.

Perhaps - and this really is just speculation - CF deals with locks that time out incorrectly when run via an event gateway?

To troubleshoot, maybe put a sleep() in the locked code so that concurrent gateway requests will timeout, and see what gets logged?

Do you have a request timeout set?