Question about Cron

djudd - September 22, 2009 - 14:25
Project:Simplenews Scheduler
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

When using this module, should I have my simplenews set to cron to send newsletters? I'm noticing that each consecutive newsletter is delayed.

I have my newsletter set to send at 3:00am every day. The first day it goes out at 3am. The next day it goes out at 3:15am. The following day at 3:30 am.

I believe the module is sending newsletters not based on the schedule, but based on the last time the schedule ran. So when cron (which runs for me every 15 minutes) runs at 3am, the scheduler creates a new edition, and then 15 minutes later Simplenews sends it. The following day the new edition will not be created until 3:15 (because it's looking at the last time it was sent) and the newsletter won't go out until 3:30.

At least that's what it seems to me.

I'm wondering if setting simplenews to send immediately would help the problem?

Also, I've noticed that if I create a newsletter issue at 10am, and schedule it to go out at 3am, it won't go out until after 10am the following day. I have to actually save it and send it manually at 3am to get the schedule on time.

#1

dgtlmoon - September 22, 2009 - 14:35

Hmm that is sounding about correct, the scheduling code definately needs a rethink and is this most weakpoint. It also assumes that a month is always going to be 30 days..

need to come up with some ideas to handle this better, so yes, i acknowledge the issue :D

#2

djudd - September 22, 2009 - 16:27

I guess my real question then, and I thank you for acknowledging that, is whether or not the scheduler relies on Simplenews using cron?

If I disable cron in Simplenews, are there any real problems you think I can expect to see with the scheduler?

I agree that the code could use some rethinking, but it's such an incredibly valuable module to me, I'm willing to use it anyway, and I thank you for your work on it.

#3

sgabe - September 25, 2009 - 17:34

@djudd: Yeah, it's because of the spool in Simplenews. When cron runs the Scheduler creates a new edition, and if Simplenews is using cron to send the newsletter this edition is waiting in the spool to be sent by next cron run. If you disable cron and use immediate expiration the newsletters will be sent in one step when cron runs.

#4

djudd - September 29, 2009 - 17:19

@sgabe, thanks so much for that information. My newsletter is about 4,000 addresses. Can you think of any pitfalls I might encounter by disabling cron?

If and when you get around to redesigning the scheduler to be more cron friendly, let me know and I'll give you a hand in testing.

#5

sgabe - September 30, 2009 - 09:53

In your case I think you should stick with cron. In my opinion is not such a good idea to send 4000 e-mails at once. I am not sure this delay because cron is a bug, this is the smooth running.

For that matter scheduling based on the last time the schedule ran is not the best way for sure. If anyone has any idea, feel free to share.

#6

gzfelix - October 26, 2009 - 15:04

Because the scheduler runs depending on the last_run's timestamp, if the last run did not run at the correct time, every run will be postponed a little while and that makes a big shift in the long term. I made a small patch to address this issue.

Please IGNORE this patch because it contains some test code.

AttachmentSize
584550_wrong_cron_interval.patch 1.71 KB

#7

gzfelix - October 26, 2009 - 15:01
Status:active» needs review

#8

gzfelix - October 26, 2009 - 15:05

The correct patch.

AttachmentSize
584550_wrong_cron_interval.patch 1.6 KB

#9

dgtlmoon - October 26, 2009 - 22:40

Aaah well spotted!

#10

sgabe - October 27, 2009 - 17:23

@gzfelix: Committed to the dev release, thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.