aboutsummaryrefslogtreecommitdiffstats
path: root/include/queue.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-09 19:57:35 -0700
committerfriendica <info@friendica.com>2015-03-09 19:57:35 -0700
commit0134a41015dd79092cb6a42ad0f7122d0af9bc6d (patch)
tree841eaab3a629984ef07fa9900303ae7c4893edae /include/queue.php
parentef035a29bc2240ccc497d76eb6e48f2434250082 (diff)
downloadvolse-hubzilla-0134a41015dd79092cb6a42ad0f7122d0af9bc6d.tar.gz
volse-hubzilla-0134a41015dd79092cb6a42ad0f7122d0af9bc6d.tar.bz2
volse-hubzilla-0134a41015dd79092cb6a42ad0f7122d0af9bc6d.zip
more work on queue optimisations
Diffstat (limited to 'include/queue.php')
-rw-r--r--include/queue.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/queue.php b/include/queue.php
index 8e97b4a1a..7d2ad3b2d 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -46,13 +46,18 @@ function queue_run($argv, $argc){
// the site is permanently down, there's no reason to attempt delivery at all, or at most not more than once
// or twice a day.
-
+ // FIXME: can we sort postgres on outq_priority and maintain the 'distinct' ?
+ // The order by max(outq_priority) might be a dodgy query because of the group by.
+ // The desired result is to return a sequence in the order most likely to be delivered in this run.
+ // If a hub has already been sitting in the queue for a few days, they should be delivered last;
+ // hence every failure should drop them further down the priority list.
+
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'DISTINCT ON (outq_posturl)';
$suffix = 'ORDER BY outq_posturl';
} else {
$prefix = '';
- $suffix = 'GROUP BY outq_posturl';
+ $suffix = 'GROUP BY outq_posturl ORDER BY max(outq_priority)';
}
$r = q("SELECT $prefix * FROM outq WHERE outq_delivered = 0 and (( outq_created > %s - INTERVAL %s and outq_updated < %s - INTERVAL %s ) OR ( outq_updated < %s - INTERVAL %s )) $suffix",
db_utcnow(), db_quoteinterval('12 HOUR'),
@@ -77,7 +82,7 @@ function queue_run($argv, $argc){
}
else {
logger('queue: queue post returned ' . $result['return_code'] . ' from ' . $rr['outq_posturl'],LOGGER_DEBUG);
- $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'",
+ $y = q("update outq set outq_updated = '%s', outq_priority = outq_priority + 10 where outq_hash = '%s'",
dbesc(datetime_convert()),
dbesc($rr['outq_hash'])
);
@@ -86,11 +91,13 @@ function queue_run($argv, $argc){
}
$result = zot_zot($rr['outq_posturl'],$rr['outq_notify']);
if($result['success']) {
+ logger('queue: deliver zot success to ' . $rr['outq_posturl'], LOGGER_DEBUG);
zot_process_response($rr['outq_posturl'],$result, $rr);
}
else {
$deadguys[] = $rr['outq_posturl'];
- $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'",
+ logger('queue: deliver zot returned ' . $result['return_code'] . ' from ' . $rr['outq_posturl'],LOGGER_DEBUG);
+ $y = q("update outq set outq_updated = '%s', outq_priority = outq_priority + 10 where outq_hash = '%s'",
dbesc(datetime_convert()),
dbesc($rr['outq_hash'])
);