From ace093bbbf92f402b27b5cc10d21e35639a1df21 Mon Sep 17 00:00:00 2001 From: ScottVerbeek Date: Mon, 6 Nov 2023 09:14:52 +1000 Subject: [PATCH] Offset to increase only when resend fails or dryrun mode - Also order by id, to ensure the same order is given everytime --- cli/resendfailed.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cli/resendfailed.php b/cli/resendfailed.php index 59820c8b0..5c63ed0cc 100644 --- a/cli/resendfailed.php +++ b/cli/resendfailed.php @@ -131,7 +131,8 @@ $sql = "SELECT x.id FROM {{$basetable}} x - WHERE $where"; + WHERE $where + ORDER BY x.id"; $limitfrom = 0; $limitnum = $options['batch']; @@ -140,21 +141,22 @@ $countfail = 0; do { + cli_write("Reading at offset {$limitfrom} ..."); $records = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); $count = count($records); - $limitfrom += $count; $counttotal += $count; - cli_writeln("Read {$count} records, next offset will be {$limitfrom}"); + cli_writeln(" read {$count} records."); $eventids = array_keys($records); if (empty($eventids)) { - continue; + break; } $mover = new \logstore_xapi\log\moveback($eventids, XAPI_REPORT_ID_ERROR); if ($options['dryrun']) { + $limitfrom += $count; continue; } @@ -162,6 +164,7 @@ $countsucc += $count; cli_writeln("$count events successfully sent for reprocessing."); } else { + $limitfrom += $count; // Increase the offset, when failed to move. $countfail += $count; cli_writeln("$count events failed to send for reprocessing."); }