Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElasticSearch plugin startup check is incomplete #2494

Open
17 tasks
abitmore opened this issue Jul 24, 2021 · 0 comments
Open
17 tasks

ElasticSearch plugin startup check is incomplete #2494

abitmore opened this issue Jul 24, 2021 · 0 comments

Comments

@abitmore
Copy link
Member

abitmore commented Jul 24, 2021

Bug Description

The checkES() function returns true even if there is an error in the response:

bool checkES(ES& es)
{
graphene::utilities::CurlRequest curl_request;
curl_request.handler = es.curl;
curl_request.url = es.elasticsearch_url + "_nodes";
curl_request.auth = es.auth;
curl_request.type = "GET";
if(doCurl(curl_request).empty())
return false;
return true;

void elasticsearch_plugin::plugin_startup()
{
graphene::utilities::ES es;
es.curl = my->curl;
es.elasticsearch_url = my->_elasticsearch_node_url;
es.auth = my->_elasticsearch_basic_auth;
if(!graphene::utilities::checkES(es))
FC_THROW_EXCEPTION(fc::exception, "ES database is not up in url ${url}", ("url", my->_elasticsearch_node_url));

It is inappropriate to use the _nodes query to check, because the user may not have specific permissions.

Actually the check should be moved to plugin_initialize(), because plugin_startup() is called after database::open() which could do a partial replay which would already need to insert data into ES. Update: this has been addressed via 679e645 in #1997.

Note: the same check is also used in elasticsearch_plugin::get_account_history(...):

vector<operation_history_object> result;
if(!graphene::utilities::checkES(es))
return result;

By the way, the same check in es_objects has a line es.auth = my->_es_objects_index_prefix; which is obviously wrong. This has been fixed via 8cc9e4c in #2570.

void es_objects_plugin::plugin_startup()
{
graphene::utilities::ES es;
es.curl = my->curl;
es.elasticsearch_url = my->_es_objects_elasticsearch_url;
es.auth = my->_es_objects_auth;
es.auth = my->_es_objects_index_prefix;
if(!graphene::utilities::checkES(es))
FC_THROW_EXCEPTION(fc::exception, "ES database is not up in url ${url}", ("url", my->_es_objects_elasticsearch_url));
ilog("elasticsearch OBJECTS: plugin_startup() begin");
}

Impacts
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.

  • API (the application programming interface)
  • Build (the build process or something prior to compiled code)
  • CLI (the command line wallet)
  • Deployment (the deployment process after building such as Docker, Travis, etc.)
  • DEX (the Decentralized EXchange, market engine, etc.)
  • P2P (the peer-to-peer network for transaction/block propagation)
  • Performance (system or user efficiency, etc.)
  • Protocol (the blockchain logic, consensus, validation, etc.)
  • Security (the security of system or user data, etc.)
  • UX (the User Experience)
  • Other (please add below)

CORE TEAM TASK LIST

  • Evaluate / Prioritize Bug Report
  • Refine User Stories / Requirements
  • Define Test Cases
  • Design / Develop Solution
  • Perform QA/Testing
  • Update Documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant