The mail spooler for ColdFusion MX 6.x/7 locks the mail spool directory when writing mail to disk. If a mail thread is trying to write a mail file to disk and is waiting to obtain the lock, it will wait up to 30 seconds and then throw a coldfusion.mail.MailSpooler$SpoolLockTimeoutException or coldfusion.mail.MailSessionException. I'm still exploring what might require the lock for so long and prevent other mail from being spooled to disk, but so far it seems well correlated with having message bodies of 12-15 MB in one case. The 30 second wait for the lock is hard coded and immutable, but writing a large message to disk shouldn't take 30 seconds in most situations. I'll update this later if I find more.
at coldfusion.mail.MailSpooler.storeMail(MailSpooler.java:670)
at coldfusion.tagext.net.MailTag.doAfterBody(MailTag.java:618)

#1 by Dan G. Switzer, II on 6/10/05 - 6:28 PM
I`ve seen this error occur recently for me as well. In my case, it appears that the error was being generated by an e-mail that was trying to attach a file that no longer existed.
Are you trying to attach a large document to your cfmail files? Maybe the the attachments aren`t being created before being sent...
-Dan
#2 by Steven Erat on 6/10/05 - 6:51 PM
#3 by Jon Jasperson on 7/1/05 - 12:58 PM
I am seeing this error to. In our case we are generating an html email report to a customer and it is over 12 MB in size.
Once the email spool and undelivr folder is cleared out, the lock on the Mail Spool still exists and is causing the error to appear in the logs every two minutes.
Any idea on how to release this lock w/o restarting ColdFusion?
#4 by Dan G. Switzer, II on 8/31/05 - 2:36 PM
Any update on this problem? This is becoming a regular headache for us.
-Dan
#5 by Joe on 2/18/06 - 6:40 PM
I will try a simple "try and catch" to see if that willl help prevent the problem.
Any other thoughts?
#6 by Sean Walker on 10/10/06 - 12:37 PM
#7 by Rob Gonda on 11/14/06 - 10:58 AM
#8 by Steven Erat on 11/14/06 - 11:49 AM
while it is still not recommended to use the ServiceFactory (unless done carefully), perhaps this might be one exception to the rule where ServiceFactory methods might be helpful.
The ColdFusion MX 7 AdminAPI offers a support mechanism to programmatically adjust the Mail Service, but it does not expose the restart() method. You can get to the MailSpoolService.restart() method via the ServiceFactory.
What do you think of this code and does it have an effect on the problem:
[cflock type="EXCLUSIVE" name="MailSpoolServiceLock" timeout="10" throwontimeout="No"]
[cfobject action="CREATE"
type="JAVA"
class="coldfusion.server.ServiceFactory"
name="factory"]
[cfset MailSpoolService = factory.getMailSpoolService()]
[cfset MailSpoolService.restart()]
[/cflock]
#9 by Patrick Whittingham on 1/19/07 - 8:35 AM
cfmx 7.0.2 enterprise
#10 by Mark Holm on 2/27/07 - 3:08 PM
#11 by Sami Hoda on 6/25/07 - 1:11 AM
Was there any permanent solution to this issue. We are now encountering it with CF 7.02 (latest).
Sami
#12 by Tom Jordahl on 7/10/07 - 6:50 PM
This lock is an internal lock and generally should only be locked for milliseconds. There is no actual locking on the directory or spool files. Switching to "spool to memory" will avoid this lock entirely (and increase performance). This would be a very good option if you are mailing 10-12mb worth of data.
#13 by jonese on 11/9/07 - 6:19 PM
#14 by Ken Smith on 4/7/08 - 2:23 PM
#15 by Cassius Seeley on 3/19/09 - 12:33 AM
I`ve had this happen in ColdFusion 8 too.
- Cass
#16 by Steven Erat on 3/19/09 - 12:38 AM
Yes, I suppose its possible to see this issue in CF8. The default timeout for the spool lock was upped from 30 to 60 seconds in CF8, but you may need more. See TomJ`s comment above about using the custom argument to set it higher with: -Dcoldfusion.spooltimeout