elasticsearch install hangs if ElasticSearch Server not running

Bug #1256118 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Robert Lyon
1.8
Fix Released
High
Robert Lyon

Bug Description

If you try to enable the elasticsearch search option in Configure site -> Site options -> Search settings when the ElasticSearch Server is not running it hangs on saving site options.

There needs to be a report back to the screen that an error occurred like 'ElasticSearch Server is not running, please start service and try again'

Actually for this to work we'd need to check if it is running before letting them choose it - because the site option is saved before the failure so coming back to the page it shows the search is set to 'elasticsearch' which is incorrect.

The error log has errors like this:

[WAR] 15 (lib/errors.php:448) An exception was thrown of class Elastica\\Exception\\ClientException. , referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) THIS IS BAD and should be changed to something extending MaharaException,, referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) unless the exception is from a third party library., referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) Original trace follows, referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/elastica/lib/Elastica/Client.php:431) No enabled connection, referer: http://mahara-testing/admin/site/options.php
Call stack (most recent first):, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Client->getConnection() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Client.php:530, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Client->request("mahara/", "DELETE", array(size 0), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Client.php:551, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Client->request("mahara/", "DELETE", array(size 0), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:405, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Index->request("", "DELETE") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:133, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Index->delete() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:184, referer: http://mahara-testing/admin/site/options.php
  * Elastica\\Index->create(array(size 3), true) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:1363, referer: http://mahara-testing/admin/site/options.php
  * ElasticsearchIndexing::create_index() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:403, referer: http://mahara-testing/admin/site/options.php
  * PluginSearchElasticsearch::reset_all_searchtypes() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:371, referer: http://mahara-testing/admin/site/options.php
  * PluginSearchElasticsearch::initialize_sitewide() at Unknown:0, referer: http://mahara-testing/admin/site/options.php
  * call_user_func_array(array(size 2), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/mahara.php:1453, referer: http://mahara-testing/admin/site/options.php
  * call_static_method("PluginSearchElasticsearch", "initialize_sitewide") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/admin/site/options.php:763, referer: http://mahara-testing/admin/site/options.php
  * siteoptions_submit(object(Pieform), array(size 65)) at Unknown:0, referer: http://mahara-testing/admin/site/options.php
  * call_user_func_array("siteoptions_submit", array(size 2)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:528, referer: http://mahara-testing/admin/site/options.php
  * Pieform->__construct(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:170, referer: http://mahara-testing/admin/site/options.php
  * Pieform::process(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:71, referer: http://mahara-testing/admin/site/options.php
  * pieform(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/admin/site/options.php:673, referer: http://mahara-testing/admin/site/options.php

Tags: search
Revision history for this message
Robert Lyon (robertl-9) wrote :

What is needed is a function like
 is_elasticsearch_server_available()

Which checks to see if a connection can be made to the ElasticSearch Server - returning true/false

That way we could use it in places like admin/extensions/pluginconfig.php?plugintype=search&pluginname=elasticsearch to complement the "The Elasticsearch plugin is currently active." message with something like "The Elasticsearch Server is/is not currently reachable".

And we could use it on search/elasticsearch/index.php to suppress the "An exception was thrown of class Elastica\Exception\ClientException. No enabled connection" warnings if the ElasticSearch Server is not able to be accessed.

We could instead have a "We were unable to process your search - please try again. If the problem persists please contact your administrator" message for the page.

Robert Lyon (robertl-9)
Changed in mahara:
assignee: nobody → Robert Lyon (robertl-9)
Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → In Progress
Revision history for this message
Robert Lyon (robertl-9) wrote :

https://reviews.mahara.org/#/c/2757/
I have added a function in elasticsearch to check to see if one can connect to the host/port with the given elasticsearch host and port details.

I tried using the inbuilt Elastica functions like getConnection() or isEnabled() to achieve a similar thing but there was instances where I could generate false positives / negatives if I ran
sudo /etc/init.d/elasticsearch stop
or
sudo /etc/init.d/elasticsearch start

After certain pages had already loaded

The inbuilt checks seem to be one page load behind actual state.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/2757
Committed: http://gitorious.org/mahara/mahara/commit/e2d208acb3616118e2ac3d7cbf1cecaf7a1eafb3
Submitter: Son Nguyen (<email address hidden>)
Branch: master

commit e2d208acb3616118e2ac3d7cbf1cecaf7a1eafb3
Author: Robert Lyon <email address hidden>
Date: Fri Nov 29 14:59:16 2013 +1300

Checking if elasticsearch can connect to host / port (bug #1256118)

Currently the getConnection() in Elastica/Client.php can give false
positive and also throws error if no connection.

What is needed is a true/false check to allow for things like notice
feedback on extensions page or giving a warning when switching to
'elasticsearch' on site options page when it is unreachable.

Change-Id: I43506f03b943d79eb019d39fe794037fc50bd05a
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Robert Lyon (robertl-9) wrote :
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/2849
Committed: http://gitorious.org/mahara/mahara/commit/6bfa2f9d01ddae4588ec4f64eba8dddfd553e070
Submitter: Son Nguyen (<email address hidden>)
Branch: 1.8_STABLE

commit 6bfa2f9d01ddae4588ec4f64eba8dddfd553e070
Author: Robert Lyon <email address hidden>
Date: Fri Nov 29 14:59:16 2013 +1300

Checking if elasticsearch can connect to host / port (bug #1256118)

Currently the getConnection() in Elastica/Client.php can give false
positive and also throws error if no connection.

What is needed is a true/false check to allow for things like notice
feedback on extensions page or giving a warning when switching to
'elasticsearch' on site options page when it is unreachable.

Change-Id: I43506f03b943d79eb019d39fe794037fc50bd05a
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.