Azure / azure-storage-cpp

Microsoft Azure Storage Client Library for C++
http://azure.github.io/azure-storage-cpp
Apache License 2.0
132 stars 147 forks source link

SDK calls hang forever when used with Fuse #250

Closed johnBuffer closed 5 years ago

johnBuffer commented 5 years ago

Hello,

When I try to use azure-storage-cpp with fuse, the blob.download_attributes() function hangs forever when called from a fuse callback. But if I run Fuse with the -f option to run it in foreground it works perfectly fine. Do you have any idea of a possible cause for this ?

Thanks

katmsft commented 5 years ago

Quick answer is no. This issue is never reported before. Can you provide a possible call stack for the hang?

johnBuffer commented 5 years ago

I'm not a Fuse expert but I think that it first calls my init callback:

void* init_azf(struct fuse_conn_info *conn)
{
    const std::string connection_str(loadConnectionString("connection_cfg"));
    const utility::string_t storage_connection_string(connection_str);
    azure_client = std::make_shared<azure::storage::cloud_storage_account>(azure::storage::cloud_storage_account::parse(storage_connection_string));

    return NULL;
}

which initializes some statics

static struct fuse_operations azure_fuse;
static std::shared_ptr<azure::storage::cloud_storage_account> azure_client;

and then the getattr callback is called (I put my logs in comments so that you can understand the logs dumps bellow):

int getattr_azf(const char *path, struct stat *stbuf)
{
    // LOG : Getattr
    // Root case
    if (strlen(path) == 1)
    {
        /* stuff */
        return 0;
    }

    std::string blob_path(&(path[1]));

    errno = 0;

    // Retrieve blob
    // LOG : Create azure client
    azure::storage::cloud_blob_client blob_client = azure_client->create_cloud_blob_client();
    // LOG : Done

    // LOG : Get container ref
    azure::storage::cloud_blob_container container(blob_client.get_container_reference(container_name));
    // LOG : Done

    // LOG : Get blob ref
    azure::storage::cloud_blob blob(container.get_blob_reference(blob_path));
    // LOG : Done
    // LOG : Check blob exists
    bool blob_exists = blob.exists();
    // LOG : Done

    if (blob_exists)
    {
        // LOG : It is a file, downloading attribs...
        blob.download_attributes();
        // LOG : Done
        azure::storage::cloud_blob_properties blob_property(blob.properties());

        /* stuff */
        return 0;
    }
    else
    {
        // LOG : Get directory ref
        azure::storage::cloud_blob_directory dir = container.get_directory_reference(blob_path);
        // LOG : Done
        if (dir.is_valid())
        {
            /* stuff */
            return 0;
        }
    }

    int storage_errno = errno;
    return -errno;
}

When I mount in foreground mode I got these logs

*** INIT ***

Getattr /5b915245311ba110386a0e0d
    Create azure client
    Done
    Get container ref
    Done
    Get blob ref
    Done
    Check blob exists
    Done
    Get directory ref
    Done
    It is a directory

Getattr /5b915245311ba110386a0e0d/raw_data
    Create azure client
    Done
    Get container ref
    Done
    Get blob ref
    Done
    Check blob exists
    Done
    Get directory ref
    Done
    It is a directory

Getattr /5b915245311ba110386a0e0d/raw_data/RecFile_1_20180904_093206_Bypass_TagsFromRTag_output_1.txt
    Create azure client
    Done
    Get container ref
    Done
    Get blob ref
    Done
    Check blob exists
    Done
    It is a file, downloading attribs...
    Done

Open called /5b915245311ba110386a0e0d/raw_data/RecFile_1_20180904_093206_Bypass_TagsFromRTag_output_1.txt

Read from 0 to 4096

Getattr /5b915245311ba110386a0e0d/raw_data/RecFile_1_20180904_093206_Bypass_TagsFromRTag_output_1.txt
    Create azure client
    Done
    Get container ref
    Done
    Get blob ref
    Done
    Check blob exists
    Done
    It is a file, downloading attribs...
    Done

And in background

*** INIT ***

Getattr /5b915245311ba110386a0e0d
    Create azure client
    Done
    Get container ref
    Done
    Get blob ref
    Done
    Check blob exists

So it seems to be hanging on bool blob_exists = blob.exists();

katmsft commented 5 years ago

Can you enable the log for Azure Storage and see if it shows more information? e.g. if the request is actually made. I suspect that it is not a Azure Storage related issue, since I can run the samples in the background and it works.

johnBuffer commented 5 years ago

Thank you for your fast answer ! I will try this and come back to you when I'll have some results.

vinjiang commented 5 years ago

Feel free to let us know if any further questions.