BESInternalError Exception thrown by the NcML handler not handled properly

Description

When a request is made for 2019-07-28T07:45:43GMT|&|25124|&|get.info_page,dap2,/usr/share/hyrax/agg/disc2.gesdisc.eosdis.nasa.gov/TRMM_3B42_daily_Aggregation_1998.ncml, and exception is thrown in this code: (marked with // ***...). This is in DDSLoader.cc

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 BESContainer* DDSLoader::addNewContainerToStorage() { // Make sure we can find the storage BESContainerStorageList *store_list = BESContainerStorageList::TheList(); VALID_PTR(store_list); // Check for URL in the _filename, 'cause that means gateway! BESContainerStorage* store; if(is_url(_filename)){ BESDEBUG("ncml", __func__ << "() - GATEWAY CONTAINER!" << endl); store = store_list->find_persistence("gateway"); } else { store = store_list->find_persistence("catalog"); } if (!store) { throw BESInternalError("couldn't find the catalog storage", __FILE__, __LINE__); } // Make a new symbol from the ncml filename // NCML_ASSERT_MSG(_dhi.container, "DDSLoader::addNewContainerToStorage(): null container!"); // string newSymbol = _dhi.container->get_symbolic_name() + "_location_" + _filename; string newSymbol = getNextContainerName() + "__" + _filename; // this will throw an exception if the location isn't found in the // catalog. Might want to catch this. Wish the add returned the // container object created. Might want to change it. store->add_container(newSymbol, _filename, ""); // *** EXCEPTION THROWN HERE // If we were successful, note the store location and symbol we added for removal later. _store = store; _containerSymbol = newSymbol; // Now look up the symbol we added BESContainer *container = store->look_for(_containerSymbol); if (!container) { throw BESInternalError("couldn't find the container we just added:" + newSymbol, __FILE__, __LINE__); } return container; }

The exception is likely caught inside the ncml_handler and processing continues, leading to a failure. The correct behavior is for a module to clean up and re-throw so the BES can recover by discarding the command in its top-most read-eval-respond loop. This might be where the error is trapped (modules/ncml_module/SaxParserWrapper.cc):

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // This is required after the end of the actual calls to the parser. #define END_SAFE_PARSER_BLOCK } \ catch (BESError& theErr) \ { \ BESDEBUG("ncml", "Caught BESError&, deferring..." << endl); \ _spw_->deferException(theErr); \ } \ catch (std::exception& ex) \ { \ BESDEBUG("ncml", "Caught std::exception&, wrapping and deferring..." << endl); \ BESInternalError _badness_("Wrapped std::exception.what()=" + string(ex.what()), __FILE__, __LINE__);\ _spw_->deferException(_badness_); \ } \ catch (...) \ { \ BESDEBUG("ncml", "Caught unknown (...) exception: deferring default error." << endl); \ BESInternalError _badness_("SaxParserWrapper:: Unknown Exception Type: ", __FILE__, __LINE__); \ _spw_->deferException(_badness_); \ } \ } \ }

Fix this catching BESInternalError explicitly at the top of the catch() block and making sure we log that and then rethrow the exception so the BES can process it without trying to continue parsing stuff. Then retry the request.

Environment

None

Status

Assignee

James Gallagher

Reporter

James Gallagher

Labels

None

Fix versions

Story Points

None

Priority

Medium
Configure