Fetching new queue tasks in a bulk to increase speed

This commit is contained in:
Michael 2017-06-13 13:51:25 +00:00
parent e232c683b6
commit 21e84e4d25

View File

@ -96,6 +96,7 @@ function poller_run($argv, $argc){
logger('Process execution failed, quitting.', LOGGER_DEBUG);
return;
}
}
// To avoid the quitting of multiple pollers only one poller at a time will execute the check
if (Lock::set('poller_worker', 0)) {
@ -112,10 +113,9 @@ function poller_run($argv, $argc){
}
Lock::remove('poller_worker');
}
}
// Quit the poller once every hour
if (time() > ($starttime + 3600)) {
// Quit the poller once every 5 minutes
if (time() > ($starttime + 300)) {
logger('Process lifetime reached, quitting.', LOGGER_DEBUG);
return;
}
@ -610,7 +610,7 @@ function find_worker_processes() {
// Are there waiting processes with a higher priority than the currently highest?
$result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
WHERE `executed` <= ? AND `priority` < ?
ORDER BY `priority`, `created` LIMIT 1",
ORDER BY `priority`, `created` LIMIT 5",
datetime_convert(), getmypid(), NULL_DATE, $highest_priority);
if (dbm::is_result($result)) {
$found = (dba::num_rows($result) > 0);
@ -632,7 +632,7 @@ function find_worker_processes() {
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
if (!$found) {
$result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 1",
$result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 5",
datetime_convert(), getmypid(), NULL_DATE);
if (dbm::is_result($result)) {
$found = (dba::num_rows($result) > 0);