0

Cpprest asserts when I try to read an azure storage append blob that another process is appending to. Below is the relevant snippet of my code. The assert occurs during .get() after some number of iterations of the while loop and way before reaching the end of the blob.

auto blob = container.get_append_blob_reference("asdf");
auto stream = blob.open_read();

while (true)
{
    auto  cb = concurrency::streams::container_buffer<vector<uint8_t>>({}, ios_base::out);
    if (stream.read(cb, 1024 * 1024).get() == 0)
    {
        break;
    }
}

Here is the assert message:

myapp: /usr/local/include/cpprest/containerstream.h:120: size_t
Concurrency::streams::details::basic_container_buffer<_CollectionType>::in_avail() const
[with _CollectionType = std::vector<unsigned char>; size_t = long unsigned int]:
Assertion `m_current_position <= m_data.size()' failed.

How can I deal with this?

Greg Clinton
  • 365
  • 1
  • 7
  • 18

1 Answers1

1

open_read() requires blobs stay unchanged during downloading. It will generate an etag condition to make sure each download is from a same blob, which is unchanged. See code ref:https://github.com/Azure/azure-storage-cpp/blob/24219e816b088fbb64a359d92ff590245ccf0b90/Microsoft.WindowsAzure.Storage/src/cloud_blob.cpp#L137

To work around this, you can disable this line of code and manual build a library.