Skip to content

Commit

Permalink
Merge pull request #1023 from SergMicar/alpha
Browse files Browse the repository at this point in the history
Try to repait tables on MDM start if corrupted
  • Loading branch information
sergejey authored Feb 9, 2022
2 parents c8d85ea + 7e4b1cb commit 019ee09
Show file tree
Hide file tree
Showing 40 changed files with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,111 @@

echo "CONNECTED TO DB" . PHP_EOL;

//если есть "поломанные" таблицы, попытаться их "вылечить"
echo "CHECK/REPAIR TABLES\n";
$tables = SQLSelect("select TABLE_NAME Tbl from information_schema.tables where TABLE_SCHEMA='".DB_NAME."' AND ENGINE !='MEMORY';");
$total = count($tables);
$checked = 0;
$broken = 0;
$repaired = 0;
$fatal = 0;
for ($i = 0; $i < $total; $i++) {
$table = $tables[$i]['Tbl'];

//echo 'Checking table [' . $table . '] ...';
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
//echo "OK\n";
$checked = $checked + 1;
} else {
echo "Checking table [" . $table . "]... broken ... try to repair ...";
$broken = $broken + 1;
SQLExec("REPAIR TABLE " . $table . ";");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "try to repair extended...";
SQLExec("REPAIR TABLE " . $table . " EXTENDED;");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "try to repair use_frm...";
SQLExec("REPAIR TABLE " . $table . " USE_FRM;");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "NO RESULT(...try restore from backup\n";
$fatal = $fatal + 1;
}
}
}
}
}
echo "CHECK/REPAIR TABLES. Total: ".$total." checked Ok: ".$checked." broken: ".$broken." repaired: ".$repaired." FATAL Errors : ".$fatal;
DebMes("CHECK/REPAIR TABLES done. Total: ".$total." checked Ok: ".$checked." broken: ".$broken." repaired: ".$repaired." FATAL Errors : ".$fatal);
echo "\n";echo('<pre>');
echo "CHECK/REPAIR TABLES\n";

This comment has been minimized.

Copy link
@xor2016

xor2016 Feb 10, 2022

Contributor

задвоение( и не знаю - стоит ли тут Debmes, \n и

 использовать? В исходнике это для скрипта красота наводилась

$tables = SQLSelect("select TABLE_NAME Tbl from information_schema.tables where TABLE_SCHEMA='".DB_NAME."' AND ENGINE !='MEMORY';");
$total = count($tables);
$checked = 0;
$broken = 0;
$repaired = 0;
$fatal = 0;
for ($i = 0; $i < $total; $i++) {
$table = $tables[$i]['Tbl'];

//echo 'Checking table [' . $table . '] ...';
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
//echo "OK\n";
$checked = $checked + 1;
} else {
echo "Checking table [" . $table . "]... broken ... try to repair ...";
$broken = $broken + 1;
SQLExec("REPAIR TABLE " . $table . ";");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "try to repair extended...";
SQLExec("REPAIR TABLE " . $table . " EXTENDED;");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "try to repair use_frm...";
SQLExec("REPAIR TABLE " . $table . " USE_FRM;");
sleep(10);
$result = SQLSelectOne("CHECK TABLE " . $table . ";");
if ($result['Msg_text'] == 'OK') {
echo "OK\n";
$repaired = $repaired + 1;
} else {
echo "NO RESULT(...try restore from backup\n";
$fatal = $fatal + 1;
}
}
}
}
}
echo "CHECK/REPAIR TABLES. Total: ".$total." checked Ok: ".$checked." broken: ".$broken." repaired: ".$repaired." FATAL Errors : ".$fatal;
DebMes("CHECK/REPAIR TABLES done. Total: ".$total." checked Ok: ".$checked." broken: ".$broken." repaired: ".$repaired." FATAL Errors : ".$fatal);
echo "\n";


// создаем табличку cyclesRun, если её нет
SQLExec('CREATE TABLE IF NOT EXISTS `cyclesRun` (`KEYWORD` char(100) NOT NULL,`DATAVALUE` char(255) NOT NULL,PRIMARY KEY (`KEYWORD`)) ENGINE=MEMORY DEFAULT CHARSET=utf8;');

Expand Down
Binary file added img/icons/status/green_color_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_128_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_128_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_128_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_256_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_256_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_256_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/lock_32_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/lock_32_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/lock_32_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_64_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_64_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/lock_64_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_128_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_128_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_128_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_256_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_256_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_256_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/network_32_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/network_32_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/icons/status/network_32_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_64_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_64_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/network_64_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/status/red_color_setup.png
Binary file added img/icons/status/system_128_green.png
Binary file added img/icons/status/system_128_red.png
Binary file added img/icons/status/system_128_yellow.png
Binary file added img/icons/status/system_256_green.png
Binary file added img/icons/status/system_256_red.png
Binary file added img/icons/status/system_256_yellow.png
Binary file modified img/icons/status/system_32_green.png
Binary file modified img/icons/status/system_32_red.png
Binary file modified img/icons/status/system_32_yellow.png
Binary file added img/icons/status/system_64_green.png
Binary file added img/icons/status/system_64_red.png
Binary file added img/icons/status/system_64_yellow.png
Binary file added img/icons/status/yellow_color_setup.png

0 comments on commit 019ee09

Please sign in to comment.