Skip to content

Commit

Permalink
Fix undefined behavior within load_tile_var_sizes (#1748)
Browse files Browse the repository at this point in the history
The `load_tile_var_sizes` is not thread-safe between TBB tasks because it
locks with an stdlib mutex. This change ensures that access to FragmentMetadata
instances are serialized.

Co-authored-by: Joe Maley <[email protected]>
  • Loading branch information
joe maley and Joe Maley authored Jul 28, 2020
1 parent 71d16d6 commit 1e4e48b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* Fixed a small memory leak when opening arrays. [#1690](https://github.com/TileDB-Inc/TileDB/pull/1690)
* Fixed an overflow in the partioning path that may result in a hang or poor read performance. [#1725](https://github.com/TileDB-Inc/TileDB/pull/1725)[#1707](https://github.com/TileDB-Inc/TileDB/pull/1707)
* Fix compilation on gcc 10.1 for blosc [#1740](https://github.com/TileDB-Inc/TileDB/pull/1740)
* Fixed a rare hang in the usage of `load_tile_var_sizes`. [#1748](https://github.com/TileDB-Inc/TileDB/pull/1748)


# TileDB v2.0.6 Release Notes
Expand Down
23 changes: 11 additions & 12 deletions tiledb/sm/subarray/subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1672,18 +1672,17 @@ Status Subarray::load_relevant_fragment_tile_var_sizes(
if (var_names.empty())
return Status::Ok();

// Load in parallel all tile var sizes metadata across fragments
auto statuses = parallel_for_2d(
0,
relevant_fragments_.size(),
0,
var_names.size(),
[&](unsigned i, uint64_t j) {
auto f = relevant_fragments_[i];
return meta[f]->load_tile_var_sizes(*encryption_key, var_names[j]);
});
for (auto st : statuses)
RETURN_NOT_OK(st);
// Load all metadata for tile var sizes among fragments.
for (const auto& var_name : var_names) {
const auto statuses =
parallel_for(0, relevant_fragments_.size(), [&](const size_t i) {
auto f = relevant_fragments_[i];
return meta[f]->load_tile_var_sizes(*encryption_key, var_name);
});

for (const auto& st : statuses)
RETURN_NOT_OK(st);
}

return Status::Ok();
}
Expand Down

0 comments on commit 1e4e48b

Please sign in to comment.