Newsletter is being sent twice from cron.php

Karlheinz - November 6, 2009 - 17:28
Project:Simplenews
Version:6.x-1.0-rc6
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello.

Whenever I send out a newsletter, it gets sent twice. This happens with all users, every time.

Looking at dblog, I can confirm that there are duplicate entries:

simplenews 11/06/2009 - 03:00 20 emails sent in 0.4 seconds. Anonymous
simplenews 11/06/2009 - 03:00 20 emails sent in 0.4 seconds. Anonymous

I'm using Simplenews 6.x-1.0-RC6, with cron.php (NOT Poormanscron), with the Cron throttle set to 20.

I just started this list, so I don't even have twenty subscribers at the moment.

#1

Sutharsan - November 7, 2009 - 16:00
Category:bug report» support request

Try this for debugging:
Check if simplenews_spool table is empty, or no record exists with status '1'.

Turn off Cron (or make sure Cron will not hit you) so you do not send emails
Simplenews setting to send using cron
Create a newsletter and save to send.
Check the content of the simplenews_spool table. ONE record should exist per address.
To clean-up: Delete the content of simplenews_spool table, delete the newsletter issue, turn on Cron.

Check if you have any other module calling simplenews_cron() or related functions. e.g. Simplenews Scheduler or a Simplenews Actions.

#2

Karlheinz - November 9, 2009 - 21:43

Check if simplenews_spool table is empty, or no record exists with status '1'.

Is there a way to do this within Drupal, or do I need to check using phpMyAdmin or similar?

If the latter, this might be a nice feature to add to the module. Provided that's possible of course.

#3

Karlheinz - November 17, 2009 - 06:48

Okay, sorry, I did all of that. There was, in fact, one entry each in the simplenews_spool table.

Here's an odd thing, though. I turned cron back on, and sent out another newsletter issue today. I've been waiting for it to arrive, and after many hours, it did not.

So, I went to the reports page to check watchdog, and I got a whole slew of cron errors:
Cron has been running for more than an hour and is most likely stuck.

I'm not sure exactly how to fix this. If I attempt to re-run cron.php manually, it fails with a "Cron run failed" message, and watchdog shows me:
Attempting to re-run cron while it is already running.

So, I disabled all cron jobs through my webhost (Dreamhost) control panel until I could figure this out.

Any ideas? Could simplenews_cron() have done something to cron.php to make it unresponsive? And, how do I kill cron.php by hand?

#4

Karlheinz - November 17, 2009 - 21:00
Priority:normal» critical

So, cron.php is STILL stuck.

Using PHPMyAdmin, I emptied out the entire simplenews_mail_spool table, and deleted all references I could find to cron_last and cron_semaphore in all tables.

Within Drupal, I went to the Simplenews > Send Mail option, UNchecked "Use cron to send newsletters," put the cron throttle to 10 (just to be safe), set the mail spool expiration to "immediate," and UNchecked "Log emails." Additionally, I put the Search settings to their lowest possible values, just to be safe.

Should I also completely clear the "cache" table in my database? Also, I found a temporary core hack to set the $semaphore variable to FALSE temporarily to get cron running again:
http://www.digitaledgesw.com/node/21

Is this recommended?

Also, I updated to the most recent version of Drupal, Simplenews, and other modules, on Nov. 12th. After that was when I got all the errors about cron.php running for too long. Is there a way to tell what exacltly is causing this? Simplenews, a core module, or another contrib module? (The others don't use cron as far as I know, so the issue is probably either Simplenews or core.)

To be clear: Right now cron.php will not run at all, under any circumstances, so I'm bumping the Priority up to Critical.

#5

Karlheinz - November 18, 2009 - 22:19
Priority:critical» normal
Status:active» closed

Things get more and more odd...

Today I went to my site again, and even though I had disabled all cron jobs through my webhost (Dreamhost), cron.php had run. What's even weirder, it had run successfully.

So, I put everything back to the way it was before in Drupal (I didn't re-enable cron in my webhost), ran cron.php again, and everything came out hunky dory.

I had already cleared out the simplenews_mail_spool table, so the newsletter issue's status was stuck on "Sending via cron." So, I:

  1. Used PHPMyAdmin to edit the simlenews_newsletters table, setting the s_status of the node to 0 (from 1);
  2. Edited the newsletter issue itself, and set the "Send newsletter" field to "Send now";
  3. Ran cron manually from the Status report page.

Everything worked, and everyone got the newsletter successfully.

Obviously there's some weirdness going on between Dreamhost and my Drupal install. It doesn't appear to be a problem with the Simplenews module. So, I'm marking this as closed.

 
 

Drupal is a registered trademark of Dries Buytaert.