Browse Source

do table optimization in separated transaction

main
ghost 2 years ago
parent
commit
b2cf9fc6a5
  1. 29
      crontab/cleaner.php

29
crontab/cleaner.php

@ -41,10 +41,10 @@ $logsCleanerDeleted = 0;
$logsCrawlerDeleted = 0; $logsCrawlerDeleted = 0;
// Begin update // Begin update
$db->beginTransaction();
try { try {
$db->beginTransaction();
// Get cleaner queue // Get cleaner queue
foreach ($db->getCleanerQueue(CLEAN_HOST_LIMIT, time() - CLEAN_HOST_SECONDS_OFFSET) as $host) { foreach ($db->getCleanerQueue(CLEAN_HOST_LIMIT, time() - CLEAN_HOST_SECONDS_OFFSET) as $host) {
@ -227,17 +227,30 @@ try {
// Commit results // Commit results
$db->commit(); $db->commit();
// Optimize tables } catch (Exception $e) {
if (CLEAN_DB_TABLES_OPTIMIZATION) {
$db->rollBack();
var_dump($e);
}
// Optimize tables
if (CLEAN_DB_TABLES_OPTIMIZATION) {
try {
$db->beginTransaction();
$db->optimize(); $db->optimize();
}
} catch(Exception $e) { $db->commit();
var_dump($e); } catch (Exception $e) {
$db->rollBack(); $db->rollBack();
var_dump($e);
}
} }
// Debug // Debug

Loading…
Cancel
Save