View Issue Details

IDProjectCategoryView StatusLast Update
0015626phplist applicationBatch Processingpublic18-05-15 18:37
Reporterduncanc 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.10.14 
Target VersionFixed in Version2.10.15 
Summary0015626: Autothrottle not delaying for the correct period
DescriptionThere was a post on the phplist forums about autothrottle not appearing to work
http://forums.phplist.com/viewtopic.php?f=24&t=36605

I've looked at the code within processqueue.php and it is delaying for an incorrect period. It calcuates the difference between the required messages/second and the actual messages/second and then delays for that * 1000000. Clearly this is wrong.

As the aim of autothrottle is to spread the sending of a batch evenly throughout the batch period, the code should be using target and actual elapsed times.
Attached is a patch to do this.
I have removed "$sent > 10" from the condition, as otherwise the message sending is not even. I have also changed the message output when verbose in enabled to more clearly reflect the time per message, rather than message rate. The original output message has been left in but commented out.

The patch replaces lines 688-708 inclusive of file admin/processqueue.php for release 2.10.14. That file is the same for release 2.10.13.
In release 2.11.6 there are some other changes to that file, so the affected lines are 839-859.
Additional InformationHere is the change to the code, also attached

           } elseif (MAILQUEUE_AUTOTHROTTLE
                 && MAILQUEUE_BATCH_SIZE && MAILQUEUE_BATCH_SIZE > 0 ) {
             $totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
             $target = (MAILQUEUE_BATCH_PERIOD / MAILQUEUE_BATCH_SIZE) * $sent;
             $delay = $target - $totaltime;

             if ($delay > 0) {
               if (VERBOSE) {
/* output($GLOBALS['I18N']->get('waiting for').' '.$delay.' '.$GLOBALS['I18N']->get('seconds').' '.
                   $GLOBALS['I18N']->get('to make sure we don\'t exceed our limit of ').MAILQUEUE_BATCH_SIZE.' '.
                   $GLOBALS['I18N']->get('messages in ').' '.MAILQUEUE_BATCH_PERIOD.$GLOBALS['I18N']->get('seconds')); */
                output(sprintf($GLOBALS['I18N']->get('waiting for %.1f seconds to meet target of %s seconds per message'),
                        $delay, (MAILQUEUE_BATCH_PERIOD / MAILQUEUE_BATCH_SIZE)
                ));
               }
               usleep($delay * 1000000);
             }
           }
Tags, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Activities

duncanc

24-07-11 09:20

developer  

processqueue.php.patch (1,010 bytes)
           } elseif (MAILQUEUE_AUTOTHROTTLE
                 && MAILQUEUE_BATCH_SIZE && MAILQUEUE_BATCH_SIZE > 0 ) {
             $totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
             $target = (MAILQUEUE_BATCH_PERIOD / MAILQUEUE_BATCH_SIZE) * $sent;
             $delay = $target - $totaltime;

             if ($delay > 0) {
               if (VERBOSE) {
/*                 output($GLOBALS['I18N']->get('waiting for').' '.$delay.' '.$GLOBALS['I18N']->get('seconds').' '.
                   $GLOBALS['I18N']->get('to make sure we don\'t exceed our limit of ').MAILQUEUE_BATCH_SIZE.' '.
                   $GLOBALS['I18N']->get('messages in ').' '.MAILQUEUE_BATCH_PERIOD.$GLOBALS['I18N']->get('seconds')); */
				output(sprintf($GLOBALS['I18N']->get('waiting for %.1f seconds to meet target of %s seconds per message'),
						$delay, (MAILQUEUE_BATCH_PERIOD / MAILQUEUE_BATCH_SIZE)
				));
               }
               usleep($delay * 1000000);
             }
           }
processqueue.php.patch (1,010 bytes)

michiel

08-08-11 15:28

manager   ~0051388

nice find!

http://phplist.svn.sourceforge.net/phplist/?rev=2796&view=rev