Compare commits

...

2 Commits

Author SHA1 Message Date
Alexander Krotov
f7e00364bf Change the order of job processing 2019-11-29 15:07:55 +01:00
Alexander Krotov
6306c82dfe Try jobs with zero retries on network probe 2019-11-28 23:54:57 +01:00

View File

@@ -976,17 +976,19 @@ pub fn interrupt_smtp_idle(context: &Context) {
/// jobs, this is tricky and probably wrong currently. Look at the
/// SQL queries for details.
fn load_jobs(context: &Context, thread: Thread, probe_network: bool) -> Vec<Job> {
let query = if !probe_network {
// processing for first-try and after backoff-timeouts:
// process jobs in the order they were added.
"SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries \
FROM jobs WHERE thread=? AND desired_timestamp<=? ORDER BY action DESC, added_timestamp;"
let query = if probe_network {
// Processing after call to dc_maybe_network():
// process all pending jobs in the order of their priority.
// If jobs have the same priority, process the
// one that was added earlier.
"SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries
FROM jobs WHERE thread=? ORDER BY action DESC, added_timestamp;"
} else {
// processing after call to dc_maybe_network():
// process _all_ pending jobs that failed before
// in the order of their backoff-times.
"SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries \
FROM jobs WHERE thread=? AND tries>0 ORDER BY desired_timestamp, action DESC;"
// Processing for the first try and after backoff-timeouts:
// process jobs that have their backoff expired
// in the order of their backoff times.
"SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries
FROM jobs WHERE thread=? AND desired_timestamp<=? ORDER BY desired_timestamp;"
};
let params_no_probe = params![thread as i64, time()];