bitshares / bitshares-core

BitShares Blockchain node and command-line wallet
https://bitshares.github.io/
Other
1.17k stars 647 forks source link

ElasticSearch plugin startup check is incomplete #2494

Open abitmore opened 3 years ago

abitmore commented 3 years ago

Bug Description

The checkES() function returns true even if there is an error in the response: https://github.com/bitshares/bitshares-core/blob/c06d09cecdd9e7526a23456986eb2f9b2b6894aa/libraries/utilities/elasticsearch.cpp#L39-L49

https://github.com/bitshares/bitshares-core/blob/c06d09cecdd9e7526a23456986eb2f9b2b6894aa/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp#L535-L543

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 https://github.com/bitshares/bitshares-core/pull/1997/commits/679e6459adf38641448cae0283d812296236c80e in #1997.

Note: the same check is also used in elasticsearch_plugin::get_account_history(...): https://github.com/bitshares/bitshares-core/blob/1d1fb99900f4aaa28fc3ea18169537994aaf6817/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp#L620-L623

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 https://github.com/bitshares/bitshares-core/pull/2570/commits/8cc9e4cac02de11cf2b631e2d39032a6e7053430 in #2570. https://github.com/bitshares/bitshares-core/blob/6b617724418d9ccbe1bb84f10ae965a0e9ceabfd/libraries/plugins/es_objects/es_objects.cpp#L403-L414

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

CORE TEAM TASK LIST