Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash getting file size on non existent blob on Azure. #4836

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion test/src/unit-vfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,19 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) {
Config config = set_config_params(disable_multipart, max_parallel_ops);
VFS vfs{&g_helper_stats, &compute_tp, &io_tp, config};

// Getting file_size on a nonexistent blob shouldn't crash on Azure
Copy link
Contributor

@KiterLuc KiterLuc Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have follow up work for this. 44271

uint64_t nbytes = 0;
URI non_existent = URI(path.to_string() + "non_existent");
if (path.is_file()) {
#ifdef _WIN32
CHECK(!vfs.file_size(non_existent, &nbytes).ok());
#else
CHECK_THROWS(vfs.file_size(non_existent, &nbytes));
#endif
} else {
CHECK(!vfs.file_size(non_existent, &nbytes).ok());
}

// Set up
bool exists = false;
if (path.is_gcs() || path.is_s3() || path.is_azure()) {
Expand Down Expand Up @@ -494,7 +507,6 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) {
CHECK(exists);

// Get file sizes
uint64_t nbytes = 0;
require_tiledb_ok(vfs.file_size(largefile, &nbytes));
CHECK(nbytes == (buffer_size));
require_tiledb_ok(vfs.file_size(smallfile, &nbytes));
Expand Down
4 changes: 2 additions & 2 deletions tiledb/sm/filesystem/azure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,9 @@ Status Azure::blob_size(const URI& uri, uint64_t* const nbytes) const {

if (response.Blobs.empty()) {
error_message = "Blob does not exist.";
} else {
*nbytes = static_cast<uint64_t>(response.Blobs[0].BlobSize);
}

*nbytes = static_cast<uint64_t>(response.Blobs[0].BlobSize);
} catch (const ::Azure::Storage::StorageException& e) {
error_message = e.Message;
}
Expand Down
Loading