Commit 1f328dd8049032f0eab7f804845f810bb7f3c82d

Authored by Conrad Vermeulen
1 parent 002e6aed

KTS-2688

"Index migration script should stop running when complete so script is not called unnecessarily"
Updated.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7672 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/indexing/indexerCore.inc.php
... ... @@ -37,7 +37,7 @@
37 37 */
38 38  
39 39 require_once('indexing/extractorCore.inc.php');
40   -
  40 +require_once(KT_DIR . '/plugins/ktcore/scheduler/schedulerUtil.php');
41 41  
42 42 class QueryResultItem
43 43 {
... ... @@ -979,11 +979,17 @@ abstract class Indexer
979 979 {
980 980 global $default;
981 981  
982   - $default->log->debug(_kt('migrateDocuments: starting'));
  982 + $default->log->info(_kt('migrateDocuments: starting'));
983 983  
984 984 if (!$this->doesDiagnosticsPass(true))
985 985 {
986   - $default->log->debug(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.'));
  986 + $default->log->info(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.'));
  987 + return;
  988 + }
  989 +
  990 + if (KTUtil::getSystemSetting('migrationComplete') == 'true')
  991 + {
  992 + $default->log->info(_kt('migrateDocuments: stopping - migration is complete.'));
987 993 return;
988 994 }
989 995  
... ... @@ -1000,7 +1006,6 @@ abstract class Indexer
1000 1006 return;
1001 1007 }
1002 1008 touch($lockFile);
1003   - $default->log->debug(_kt('migrateDocuments: starting!'));
1004 1009  
1005 1010 $startTime = KTUtil::getSystemSetting('migrationStarted');
1006 1011 if (is_null($startTime))
... ... @@ -1010,7 +1015,7 @@ abstract class Indexer
1010 1015  
1011 1016 $maxLoops = 5;
1012 1017  
1013   - $max = floor($max / $maxLoops);
  1018 + $max = ceil($max / $maxLoops);
1014 1019  
1015 1020 $start =KTUtil::getBenchmarkTime();
1016 1021 $noDocs = false;
... ... @@ -1035,7 +1040,6 @@ abstract class Indexer
1035 1040 $docs = count($result);
1036 1041 if ($docs == 0)
1037 1042 {
1038   - $default->log->info(_kt('migrateDocuments: no more documents to migrate'));
1039 1043 $noDocs = true;
1040 1044 break;
1041 1045 }
... ... @@ -1050,7 +1054,7 @@ abstract class Indexer
1050 1054 {
1051 1055 $sql = "DELETE FROM document_text WHERE document_id=$docId";
1052 1056 DBUtil::runQuery($sql);
1053   - $default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!',$docId)));
  1057 + $default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!'),$docId));
1054 1058 continue;
1055 1059 }
1056 1060  
... ... @@ -1091,11 +1095,13 @@ abstract class Indexer
1091 1095 KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime',0) + $time);
1092 1096 KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments',0) + $numDocs);
1093 1097  
1094   - $default->log->debug(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time));
  1098 + $default->log->info(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time));
1095 1099 if ($noDocs)
1096 1100 {
1097 1101 $default->log->info(_kt('migrateDocuments: Completed!'));
1098   - KTUtil::setSystemSetting('migrationComplete', true);
  1102 + KTUtil::setSystemSetting('migrationComplete', 'true');
  1103 + schedulerUtil::deleteByName('Index Migration');
  1104 + $default->log->debug(_kt('migrateDocuments: Disabling \'Index Migration\' task by removing scheduler entry.'));
1099 1105 }
1100 1106 }
1101 1107  
... ...