4

I've been dealing with this issue on and off for YEARS, dating back to CF 5 and 6.

Out of the blue, Coldfusion just stops delivering email, and the mail just keeps building up in the queue.

To restart the service I can restart coldfusion OR run the following code:

  <cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
  <cfset MailSpoolService = sFactory.mailSpoolService>
  <cfset MailSpoolService.start()>

The solution above is a fix noted on stackoverflow: https://stackoverflow.com/questions/94932/coldfusion-mail-queue-stops-processing

My goal would be to find a log or something that would help point me to the cause of the issue.

Is there a log that will tell me what is causing the mailspoolservice to crash? I can't seem to locate any errors in the CF Admin.

I have also tried to regenerate this issue, and I can't.

I'm currently running CF9 latest hotfixes applied, on windows 2008 r2

steve
  • 215
  • 1
  • 3
  • 8

2 Answers2

3

What version of ColdFusion are you running now and on what platform?

You can add some logging information via the ColdFusion administrator under the mail settings. See the documentation for mail logging on ColdFusion 9 here.

Error Log Severity

From the drop-down list object, select the type of SMTP-related error message to write to a log file. The options are the following:

  • Debug (contains Information, Warning, and Error)

  • Information (contains Warning and Error)

  • Warning (contains Error)

  • Error

ColdFusion writes sent-mail and mail-error logs to the following directories:

  • \coldfusion9\logs (Windows server configuration)

  • /opt/coldfusion9/log (Solaris and Linux server configuration)

  • cf_webapp_root/WEB-INF/cfusion/logs (multiserver and J2EE configurations, all platforms)

The email log files generated are:

  • mailsent.log - Records sent e-mail messages.

  • mail.log - Records general e-mail errors.

What is your mail logging set to now?

Miguel-F
  • 302
  • 3
  • 11
  • I just updated my question with in. Running windows 2008r2, CF9 (but have been having this issue since windows 2003 and cf5 - finally sick of dealing with it). My smtp log was on information, moved it up to debug. The Mail log doesnt reflect any errors relating to events at the time of the error. For example error happened at 10am and last entry was 2 days ago. Mail sent doesnt get updated beyond the date/time of last message sent and doesnt include any error. No application errors either. Was hoping there was a java level log. – steve Apr 01 '13 at 16:27
  • Am I understanding your issue correctly; the mail files are not being moved to the Undelivr folder, they are stuck in the Spool folder? I'm not really sure how useful the error logging I described above is. I was hoping your setting was off. At the information level you should be getting any errors. Maybe debug will give you something. Could your ColdFusion server be losing it's connection to the mail server? – Miguel-F Apr 01 '13 at 16:42
  • The problem that I am having and that other people are having is that the spool manager just quits working. Coldfusion drops the message in the spool folder and the spooler doesnt move it to the SMTP or Undeliverable folder (if that was going to be the case). They just sit until you force- restart the mail spool OR restart coldfusion. – steve Apr 01 '13 at 16:46
  • Have you noticed anything common about the mail files that get stuck? Are they small or large in size? Are they to particular addresses? Is your server processing a lot of email? Does any mail go through while this is happening or is ALL mail suspended? Do you have multiple ColdFusion instances on the server or just one? If more than one, do they all point to the same SMTP server? Do they all experience this? At the same time? Sorry, lots of questions and no answers. Just trying to gather more information. – Miguel-F Apr 01 '13 at 16:50
  • I can't find anything common. It could get stuck while sending a batch of newsletters or a transactional email. The emails are usually smaller... 4-5kb up to 20kb. The cfmail tag continues to work. I'll get notified from a client that they arent receiving emails they are expecting. When I look at the spool folder it could have anywhere from 25 to 10k messages waiting to go out. I'm only running 1 instance of CF. This problem is in the chain before SMTP would even kick in. – steve Apr 01 '13 at 16:55
  • Did you see this other post? http://stackoverflow.com/questions/94932/coldfusion-mail-queue-stops-processing – Miguel-F Apr 01 '13 at 17:12
  • Yes, I had actually referenced that within the original question. They posted the same workaround I use to "activate" mail again, but no actual determination on how to "prevent" the issue from happening. – steve Apr 01 '13 at 17:24
  • Please report back after the next failure. I'm curious if the debug log setting gives you any useful information. – Miguel-F Apr 01 '13 at 20:40
  • Issue popped up again within the hour. Debug mode added a tiny bit of help. Every 30 seconds it ads an entry telling you the mail service ran and shows you how many messages in the queue. It helped me determine the exact time it crashed. I looked in my application log and for at least this event, I found a "GC overhead limit exceeded the specific sequence of the files included or processed is :..." error... however nothing specific to the crashing of the mail service – steve Apr 02 '13 at 15:47
  • Interesting. (By the way, I have just been dealing with that specific GC issue myself.) I assume you are caching your mail server connection. By doing so, information is being stored in memory. I can't even pretend to say I completely understand how Java uses it's memory allocation and the garbage collection process. I guess you can keep monitoring and see if you get that GC error every time this happens. You can easily get passed that particular GC error if you can give more memory to the Java server. What are your JVM settings now and how much memory does your server have? – Miguel-F Apr 02 '13 at 16:12
  • For caching: some users use the default cfmail server (the ones who do light mailing). Other's who do heavier use sendgrid and that is specified in the cfmail tag with their login credentials. My heap size looks like it was the default of 512mb. I just doubled it. I have 16gb on the server an only 6.5 was in play. How would I get GC error details? – steve Apr 02 '13 at 16:25
  • It depends on the java platform you are using (Sun, IBM, etc) but here is a good reference: http://www.talkingtree.com/blog/index.cfm/2010/9/9/JVM-Memory-Management-and-ColdFusion-Log-Analysis – Miguel-F Apr 02 '13 at 16:29
  • great. thanks for sticking with me and the help! I am now going to play around with the server monitor and see if that sheds new light on how the memory is being used. – steve Apr 02 '13 at 16:36
  • Do you mean the ColdFusion server monitor? Be careful with that. I have not used it in years but from what I remember it was VERY heavy. It might slow your production server down. Maybe they have made it better in the newer versions. Let me know how it goes. – Miguel-F Apr 02 '13 at 16:40
1

On one of our production servers (coldfusion 8 for backward compatibiliy reasons), we encounter this problem as well from time to time, although quite rarely, maybe once in half a year or so. I put this on a tiny scheduled task, running e.g. once an hour, to observe the mail spool folder for stucking and, in case it does, restarting the service (not cf server, but only the spool service):

Mail-Spool-Directory is from coldfusion 8 default dir:

<cfdirectory directory="C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\Mail\Spool" name="dirQuery" action="LIST" sort = "datelastmodified ASC">

<cfquery name="oldest" dbtype="query" maxrows="1">
    SELECT dateLastModified  FROM dirQuery ORDER BY dateLastModified 
</cfquery>
<cfif oldest.recordcount GTE 1>
    <cfif DateDiff("h",oldest.dateLastModified ,now()) GTE 2>
        DO RESTART MAILQUEUE SERVICE...
        <cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
        <cfset MailSpoolService = sFactory.mailSpoolService>
        <cfset MailSpoolService.stop()>
        <cfset MailSpoolService.start()>
        done
    <cfelse>
        files there but younger than 2 h
    </cfif>
<cfelse>
    dir empty
</cfif>