diff --git a/.github/workflows/libtiledb-ci.yml b/.github/workflows/libtiledb-ci.yml index 7e7a9e907e..eb2662f70b 100644 --- a/.github/workflows/libtiledb-ci.yml +++ b/.github/workflows/libtiledb-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Build libTileDB-SOMA run: TILEDBSOMA_COVERAGE="--coverage" ./scripts/bld --no-tiledb-deprecated=true - name: Run libTileDB-SOMA unittests - run: ctest --test-dir build/libtiledbsoma -C Release --verbose --rerun-failed --output-on-failur + run: ctest --test-dir build/libtiledbsoma -C Release --verbose --rerun-failed --output-on-failure - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/libtiledbsoma/src/soma/managed_query.cc b/libtiledbsoma/src/soma/managed_query.cc index d87b902bf0..2fe4838f46 100644 --- a/libtiledbsoma/src/soma/managed_query.cc +++ b/libtiledbsoma/src/soma/managed_query.cc @@ -55,9 +55,6 @@ ManagedQuery::ManagedQuery( } void ManagedQuery::close() { - if (query_future_.valid()) { - query_future_.get(); - } array_->close(); } @@ -292,8 +289,13 @@ void ManagedQuery::submit_read() { query_submitted_ = true; query_future_ = std::async(std::launch::async, [&]() { LOG_DEBUG("[ManagedQuery] submit thread start"); - query_->submit(); + try { + query_->submit(); + } catch (const std::exception& e) { + return StatusAndException(false, e.what()); + } LOG_DEBUG("[ManagedQuery] submit thread done"); + return StatusAndException(true, "success"); }); } @@ -305,6 +307,17 @@ std::shared_ptr ManagedQuery::results() { if (query_future_.valid()) { LOG_DEBUG(fmt::format("[ManagedQuery] [{}] Waiting for query", name_)); query_future_.wait(); + LOG_DEBUG( + fmt::format("[ManagedQuery] [{}] Done waiting for query", name_)); + + auto retval = query_future_.get(); + if (!retval.succeeded()) { + throw TileDBSOMAError(fmt::format( + "[ManagedQuery] [{}] Query FAILED: {}", + name_, + retval.message())); + } + } else { throw TileDBSOMAError( fmt::format("[ManagedQuery] [{}] 'query_future_' invalid", name_)); diff --git a/libtiledbsoma/src/soma/managed_query.h b/libtiledbsoma/src/soma/managed_query.h index e0728a335c..df27157f0a 100644 --- a/libtiledbsoma/src/soma/managed_query.h +++ b/libtiledbsoma/src/soma/managed_query.h @@ -47,6 +47,26 @@ namespace tiledbsoma { using namespace tiledb; +// Probably we should just use a std::tuple here +class StatusAndException { + public: + StatusAndException(bool succeeded, std::string message) + : succeeded_(succeeded) + , message_(message) { + } + + bool succeeded() { + return succeeded_; + } + std::string message() { + return message_; + } + + private: + bool succeeded_; + std::string message_; +}; + class ManagedQuery { public: //=================================================================== @@ -411,7 +431,7 @@ class ManagedQuery { bool query_submitted_ = false; // Future for asyncronous query - std::future query_future_; + std::future query_future_; }; }; // namespace tiledbsoma