"No such index" 加载自定义模块时 ElasticSearch 控制器出错

"No such index" error in ElasticSearch controller when loading custom module

我在 SugarCRM 8.0.0 登台实例上创建了一堆自定义 modules 捆绑在一个包中。为了迁移这些 modules 我决定 publish 包,这样我就可以将可安装的 zip 上传到另一个实例。不幸的是,当我尝试使用模块加载器在接收实例上上传 zip 文件时,安装在 80% 时挂起,并在 sugarlog

中给出错误

I am 运行 ElasticSearch 5.4 这与 Sugar I am 运行 的实例兼容。这是日志中显示的错误:

Thu Mar 28 17:54:19 2019 [1786][1][FATAL] Elasticsearch request failure: no such index [index: ab164c0013004724c8eba5f5f6f3f646_shared]
Thu Mar 28 17:54:19 2019 [1786][1][FATAL] Exception in Controller: Elastica\Exception\ResponseException: no such index [index: ab164c0013004724c8eba5f5f6f3f646_shared] in /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:179
Stack trace:
#0 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Request.php(193): Elastica\Transport\Http->exec(Object(Elastica\Request), Array)
#1 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Client.php(674): Elastica\Request->send()
#2 /var/www/html/SugarPro-Full-8/src/Elasticsearch/Adapter/Client.php(355): Elastica\Client->request('ab164c001300472...', 'PUT', Array, Array)
#3 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Client.php(706): Sugarcrm\Sugarcrm\Elasticsearch\Adapter\Client->request('ab164c001300472...', 'PUT', Array, Array)
#4 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Index.php(562): Elastica\Client->requestEndpoint(Object(Elasticsearch\Endpoints\Indices\Mapping\Put))
#5 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Type.php(523): Elastica\Index->requestEndpoint(Object(Elasticsearch\Endpoints\Indices\Mapping\Put))
#6 /var/www/html/SugarPro-Full-8/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php(250): Elastica\Type->requestEndpoint(Object(Elasticsearch\Endpoints\Indices\Mapping\Put))
#7 /var/www/html/SugarPro-Full-8/src/Elasticsearch/Index/IndexManager.php(486): Elastica\Type\Mapping->send()
#8 /var/www/html/SugarPro-Full-8/src/Elasticsearch/Index/IndexManager.php(390): Sugarcrm\Sugarcrm\Elasticsearch\Index\IndexManager->sendMapping(Object(Elastica\Type\Mapping))
#9 /var/www/html/SugarPro-Full-8/src/Elasticsearch/Index/IndexManager.php(285): Sugarcrm\Sugarcrm\Elasticsearch\Index\IndexManager->createIndices(Object(Sugarcrm\Sugarcrm\Elasticsearch\Index\IndexCollection), Object(Sugarcrm\Sugarcrm\Elasticsearch\Analysis\AnalysisBuilder), Object(Sugarcrm\Sugarcrm\Elasticsearch\Mapping\MappingCollection), false)
#10 /var/www/html/SugarPro-Full-8/src/Elasticsearch/Index/IndexManager.php(200): Sugarcrm\Sugarcrm\Elasticsearch\Index\IndexManager->syncIndices(Array, false)
#11 /var/www/html/SugarPro-Full-8/src/SearchEngine/Engine/Elastic.php(113): Sugarcrm\Sugarcrm\Elasticsearch\Index\IndexManager->addMappings(Array)
#12 /var/www/html/SugarPro-Full-8/ModuleInstall/ModuleInstaller.php(3489): Sugarcrm\Sugarcrm\SearchEngine\Engine\Elastic->addMappings(Array)
#13 /var/www/html/SugarPro-Full-8/ModuleInstall/ModuleInstaller.php(168): ModuleInstaller->setup_elastic_mapping()
#14 /var/www/html/SugarPro-Full-8/modules/Administration/UpgradeWizard_commit.php(342): ModuleInstaller->install('cache/upgrades/...')
#15 /var/www/html/SugarPro-Full-8/include/MVC/View/SugarView.php(489): require_once('/var/www/html/S...')
#16 /var/www/html/SugarPro-Full-8/include/MVC/View/views/view.classic.php(43): SugarView->includeClassicFile('cache/upgrades/...')
#17 /var/www/html/SugarPro-Full-8/include/MVC/View/SugarView.php(152): ViewClassic->display(Array)
#18 /var/www/html/SugarPro-Full-8/include/MVC/Controller/SugarController.php(351): SugarView->process(Array)
#19 /var/www/html/SugarPro-Full-8/include/MVC/Controller/SugarController.php(299): SugarController->processView()
#20 /var/www/html/SugarPro-Full-8/include/MVC/SugarApplication.php(198): SugarController->execute()
#21 /var/www/html/SugarPro-Full-8/index.php(27): SugarApplication->execute()
#22 {main}
Thu Mar 28 17:54:19 2019 [1786][1][FATAL] ERROR: rmdir_recursive(): argument cache/upgrades/temp/ICB8l3 is not a file or a dir.

我试过多次修复和重建,也试过再次发布包以重新检查是否有任何我可能没有注意到的错误。我尝试使用另一个实例进行上传,以防我当前的实例可能已损坏,但观察到的情况相同。我不明白是什么导致了这个问题。

Elasticsearch request failure: no such index [index: ...]

这表明 Elasticsearch 索引丢失(或损坏)。

如何修复:

  • 以管理员权限登录 Sugar
  • 转到管理 -> 搜索(或全局搜索 在某些版本的 Sugar 中)
  • 单击“计划系统索引”按钮(并确认与性能相关的 javascript 警报,如果有的话) , 之后会出现一个带有列表的弹出窗口window
  • 在弹窗中向下滚动 window and select "索引时删除已有数据,仅[=86=中的数据]ed 模块将被索引。”。
    这一步很重要。如果您忘记 select 此复选框,重新索引将失败(因为它会尝试重新填充现有索引,而不是从头开始重新创建它)。
  • 点击“索引”按钮进行确认。这将(重新)创建您需要的索引。
  • 现在您应该可以再次安装新模块了!

备注:

  • Elasticsearch索引的名称是基于config.php$sugar_config['unique_key']的值。更改此值并重建缓存将导致 Sugar 寻找新的索引名称。您必须如上所述触发重新索引(除非您以某种方式在 Elasticsearch 中重命名索引,以便再次找到它)。

  • 除非您的 cron/Schedulers 是 运行,否则新创建的索引可能会保持为空(尽管这对于模块安装应该足够了)。如果 Elastic Search Scheduler 是 运行,它将在下一个 minutes/hours 内用数据填充索引,您可以使用 Sugar 右上角的搜索。

  • 如果您有权访问服务器的主机系统,您还可以选择从命令行重新创建索引:
    bin/sugarcrm search:silent_reindex --clearData
    bin/sugarcrm search:silent_reindex_mp --clearData(多线程)
    文件 bin/sugarcrm 必须对此具有可执行权限。
    (第一种单线程方式也可以通过前缀 php 代替)
    如果您的 Sugar 版本非常过时,最后一个或两个命令可能不可用。