Skip to content

Commit

Permalink
Fix segfault by not spawning multiple ManagedQueries per SOMAArray
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv committed Jan 11, 2024
1 parent 4bffa30 commit 21a16a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
10 changes: 6 additions & 4 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,21 @@ def read(
Lifecycle:
Experimental.
"""
del batch_size, platform_config # Currently unused.
del batch_size # Currently unused.
_util.check_unpartitioned(partitions)
self._check_open_read()

ts = None
if self._handle._handle.timestamp is not None:
ts = (0, self._handle._handle.timestamp)

sr = self._handle._handle
sr.reset(column_names or [], "auto", _util.to_clib_result_order(result_order))
sr = clib.SOMADataFrame.open(self._handle._handle.uri, clib.OpenMode.read, platform_config or {}, column_names or [], _util.to_clib_result_order(result_order), ts)

if value_filter is not None:
sr.set_condition(QueryCondition(value_filter), self._handle.schema)

self._set_reader_coords(sr, coords)

# TODO: platform_config
# TODO: batch_size

return TableReadIter(sr)
Expand Down
23 changes: 1 addition & 22 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,6 @@ void SOMAArray::open(
void SOMAArray::close() {
// Close the array through the managed query to ensure any pending queries
// are completed.
if (managed_query_future_.valid()) {
managed_query_future_.wait();
// mq_->close();
}
// else {
// throw TileDBSOMAError(
// fmt::format("[SOMAArray] 'managed_query_future_' invalid"));
// }
mq_->close();
}

Expand Down Expand Up @@ -255,20 +247,7 @@ std::optional<std::shared_ptr<ArrayBuffers>> SOMAArray::read_next() {

first_read_next_ = false;

// mq_->submit_read();

managed_query_future_ = std::async(std::launch::async, [&]() {
LOG_DEBUG("[SOMAArray] submit thread start");
mq_->submit_read();
LOG_DEBUG("[SOMAArray] submit thread done");
});

if (managed_query_future_.valid()) {
LOG_DEBUG("[SOMAArray] Waiting for query");
managed_query_future_.wait();
} else {
throw TileDBSOMAError("[SOMAArray] 'managed_query_future_' invalid");
}
mq_->submit_read();

// Return the results, possibly incomplete
return mq_->results();
Expand Down
3 changes: 0 additions & 3 deletions libtiledbsoma/src/soma/soma_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,6 @@ class SOMAArray {

// Unoptimized method for computing nnz() (issue `count_cells` query)
uint64_t nnz_slow();

// Future for asyncronous managed query
std::future<void> managed_query_future_;
};

} // namespace tiledbsoma
Expand Down

0 comments on commit 21a16a0

Please sign in to comment.