Skip to content

Commit

Permalink
Merge pull request #864 from it-at-m/feature-zms-3483-mysql-server-ha…
Browse files Browse the repository at this point in the history
…s-gone-away

Feature zms 3483 mysql server has gone away
  • Loading branch information
manjencic authored Feb 18, 2025
2 parents 972ed05 + 1409e25 commit 101ec49
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions zmsdb/src/Zmsdb/Helper/CalculateSlots.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function readLastRun()
return $updateTimestamp;
}

public function writeMaintenanceQueries()
public function writeMaintenanceQueries($daily = false)
{
$sqlList = (new \BO\Zmsdb\Config())->readProperty('status__calculateSlotsMaintenanceSQL');
if ($sqlList) {
Expand All @@ -80,11 +80,15 @@ public function writeMaintenanceQueries()
}
return \BO\Zmsdb\Connection\Select::writeCommit();
}
return false;

if ($daily) {
(new \BO\Zmsdb\Slot())->writeOptimizedSlotTables();
$this->log("Optimized tables successfully");
}
}


public function writeCalculations(\DateTimeInterface $now, $delete = false)
public function writeCalculations(\DateTimeInterface $now, $daily = false)
{
\BO\Zmsdb\Connection\Select::setTransaction();
\BO\Zmsdb\Connection\Select::getWriteConnection();
Expand All @@ -104,7 +108,7 @@ public function writeCalculations(\DateTimeInterface $now, $delete = false)
\BO\Zmsdb\Connection\Select::writeCommit();
$updateTimestamp = $this->readLastRun();
$this->log("Last Run on time=" . $updateTimestamp);
if ($delete) {
if ($daily) {
$this->deleteOldSlots($now);
}
$scopeList = (new \BO\Zmsdb\Scope())->readList(1);
Expand Down Expand Up @@ -132,7 +136,9 @@ public function writeCalculations(\DateTimeInterface $now, $delete = false)

\BO\Zmsdb\Connection\Select::writeCommit();
$this->log("Slot calculation finished");
$this->writeMaintenanceQueries();
$this->writeMaintenanceQueries($daily);

return true;
}

protected function writeCalculatedScope(\BO\Zmsentities\Scope $scope, \DateTimeInterface $now)
Expand Down Expand Up @@ -187,8 +193,6 @@ public function deleteOldSlots(\DateTimeInterface $now)
if ($slotQuery->deleteSlotsOlderThan($now)) {
\BO\Zmsdb\Connection\Select::writeCommit();
$this->log("Deleted old slots successfully");
$slotQuery->writeOptimizedSlotTables();
$this->log("Optimized tables successfully");
}
}
}

0 comments on commit 101ec49

Please sign in to comment.