From 29d909ad081f15e2a126c233f91f16be50ea3dd5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Nov 2022 15:43:14 +1100 Subject: [PATCH] Fixes for SendReminders firing twice --- app/Jobs/Util/ReminderJob.php | 12 ++++++++++-- config/ninja.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 403ef964a3..8b8a4610d5 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -50,11 +50,20 @@ class ReminderJob implements ShouldQueue $this->processReminders(); } else { //multiDB environment, need to + /* foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); nlog("set db {$db}"); $this->processReminders(); } + */ + //24-11-2022 fix for potential memory leak during a long running process, the second reminder may run twice + foreach (config('ninja.dbs') as $db) { + MultiDB::setDB($db); + nlog("set db {$db}"); + $this->processReminders(); + } + } } @@ -79,9 +88,8 @@ class ReminderJob implements ShouldQueue if ($invoice->isPayable()) { $reminder_template = $invoice->calculateTemplate('invoice'); nlog("reminder template = {$reminder_template}"); - $invoice->service()->touchReminder($reminder_template)->save(); $invoice = $this->calcLateFee($invoice, $reminder_template); - + $invoice->service()->touchReminder($reminder_template)->save(); $invoice->service()->touchPdf(); //20-04-2022 fixes for endless reminders - generic template naming was wrong diff --git a/config/ninja.php b/config/ninja.php index b850fef4ff..45ec406ae1 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -211,4 +211,5 @@ return [ 'dev_mode' => env("YODLEE_DEV_MODE", false), 'config_name' => env("YODLEE_CONFIG_NAME", false), ], + 'dbs' => ['db-ninja-01','db-ninja-02'] ];