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

[BUG] CopyStatus is not updated after copy is finished #19263

Closed
WillRock19 opened this issue Mar 5, 2021 · 6 comments
Closed

[BUG] CopyStatus is not updated after copy is finished #19263

WillRock19 opened this issue Mar 5, 2021 · 6 comments
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@WillRock19
Copy link

Describe the bug
I'm making the migration from Microsoft.WindowsAzure.Storage.Blob versio 9.3.2.0 to Azure.Storage.Blobs version 12.8.0.0 and trying to replicate the CopyBlobData functionality. In the oldest version, we could check a property CopyStatus to see if the copy is finished. In the new one we still have this property, but it's never updated and so we can never know if the copy has ended. See more bellow:

1. Original code

public virtual void CopyFromBlob(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
    var sourceContainer = GetContainer(sourceConnectionString, sourceContainerName);
    CloudBlockBlob sourceBlockBlob = sourceContainer.GetBlockBlobReference(sourceBlobName);

    var targetContainer = GetContainer(targetConnectionString, targetContainerName);
    CloudBlockBlob targetBlockBlob = targetContainer.GetBlockBlobReference(targetBlobName);

    targetBlockBlob.StartCopy(sourceBlockBlob);

    while (targetBlockBlob.CopyState.Status == Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Pending)
    {
        Thread.Sleep(500);
    }

    if (targetBlockBlob.CopyState.Status != Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Success)
    {
        throw new Exception("Copy failed: " + targetBlockBlob.CopyState.Status);
    }
}

2. New version

public virtual void CopyFromBlobNew(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
    var sourceContainer = GetContainerNew(sourceConnectionString, sourceContainerName);
    var sourceBlob = sourceContainer.GetBlobClient(sourceBlobName);
    
    var targetContainer = GetContainerNew(targetConnectionString, targetContainerName);
    var targetBlob = targetContainer.GetBlobClient(targetBlobName);

        var copyInformation = targetBlob.SyncCopyFromUri(sourceBlob.Uri);

        while (copyInformation.Value.CopyStatus == Azure.Storage.Blobs.Models.CopyStatus.Pending) 
        {
            Thread.Sleep(500);
        }

        if (copyInformation.Value.CopyStatus != Azure.Storage.Blobs.Models.CopyStatus.Success)
        {
            throw new Exception("Copy failed: " + copyInformation.Value.CopyStatus);
        }
}

The problem is: the CopyStatus property inside the BlobCopyInfo object that the SyncCopyFromUri method returns is never updated. I've eve tried to get the blob properties directly, but, as you can see bellow, the CopyStatus property still with the wrong value even if there is no more data to copy:

image

Expected behavior
The CopyStatus property should be updated as soon as the copy is finished.

Actual behavior (include Exception or Stack Trace)
The CopyStatus is never updated

To Reproduce
Described above

Environment:

  • Azure.Storage.Blobs version 12.8.0.0
  • Windows 10, .NET Framework 4.7
  • IDE and version : Version 16.8.5
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 5, 2021
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files) labels Mar 5, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 5, 2021
@ghost
Copy link

ghost commented Mar 5, 2021

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details

Describe the bug
I'm making the migration from Microsoft.WindowsAzure.Storage.Blob versio 9.3.2.0 to Azure.Storage.Blobs version 12.8.0.0 and trying to replicate the CopyBlobData functionality. In the oldest version, we could check a property CopyStatus to see if the copy is finished. In the new one we still have this property, but it's never updated and so we can never know if the copy has ended. See more bellow:

1. Original code

public virtual void CopyFromBlob(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
    var sourceContainer = GetContainer(sourceConnectionString, sourceContainerName);
    CloudBlockBlob sourceBlockBlob = sourceContainer.GetBlockBlobReference(sourceBlobName);

    var targetContainer = GetContainer(targetConnectionString, targetContainerName);
    CloudBlockBlob targetBlockBlob = targetContainer.GetBlockBlobReference(targetBlobName);

    targetBlockBlob.StartCopy(sourceBlockBlob);

    while (targetBlockBlob.CopyState.Status == Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Pending)
    {
        Thread.Sleep(500);
    }

    if (targetBlockBlob.CopyState.Status != Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Success)
    {
        throw new Exception("Copy failed: " + targetBlockBlob.CopyState.Status);
    }
}

2. New version

public virtual void CopyFromBlobNew(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
    var sourceContainer = GetContainerNew(sourceConnectionString, sourceContainerName);
    var sourceBlob = sourceContainer.GetBlobClient(sourceBlobName);
    
    var targetContainer = GetContainerNew(targetConnectionString, targetContainerName);
    var targetBlob = targetContainer.GetBlobClient(targetBlobName);

        var copyInformation = targetBlob.SyncCopyFromUri(sourceBlob.Uri);

        while (copyInformation.Value.CopyStatus == Azure.Storage.Blobs.Models.CopyStatus.Pending) 
        {
            Thread.Sleep(500);
        }

        if (copyInformation.Value.CopyStatus != Azure.Storage.Blobs.Models.CopyStatus.Success)
        {
            throw new Exception("Copy failed: " + copyInformation.Value.CopyStatus);
        }
}

The problem is: the CopyStatus property inside the BlobCopyInfo object that the SyncCopyFromUri method returns is never updated. I've eve tried to get the blob properties directly, but, as you can see bellow, the CopyStatus property still with the wrong value even if there is no more data to copy:

image

Expected behavior
The CopyStatus property should be updated as soon as the copy is finished.

Actual behavior (include Exception or Stack Trace)
The CopyStatus is never updated

To Reproduce
Described above

Environment:

  • Azure.Storage.Blobs version 12.8.0.0
  • Windows 10, .NET Framework 4.7
  • IDE and version : Version 16.8.5
Author: WillRock19
Assignees: -
Labels:

Client, Service Attention, Storage, customer-reported, needs-team-attention, needs-triage, question

Milestone: -

@jsquire
Copy link
Member

jsquire commented Mar 5, 2021

Thank you for your feedback. Tagging and routing to the team best able to assist.

@seanmcc-msft
Copy link
Member

@WillRock19, this is by design.

copyInformation is not a dynamic object, and will not be updated.

I would recommend this approach instead:

public virtual async Task CopyFromBlobNewAsync(
    string sourceConnectionString,
    string sourceContainerName,
    string sourceBlobName,
    string targetConnectionString,
    string targetContainerName,
    string targetBlobName)
{
    BlobContainerClient sourceContainer = GetContainerNew(sourceConnectionString, sourceContainerName);
    BlobClient sourceBlob = sourceContainer.GetBlobClient(sourceBlobName);
    
    BlobContainerClient targetContainer = GetContainerNew(targetConnectionString, targetContainerName);
    BlobClient targetBlob = targetContainer.GetBlobClient(targetBlobName);

        await targetBlob.SyncCopyFromUriAsync(sourceBlob.Uri);
        Response<BlobProperties> blobPropertiesResponse = await targetBlob.GetPropertiesAsync();
        while (blobPropertiesResponse.Value.CopyStatus == Azure.Storage.Blobs.Models.CopyStatus.Pending) 
        {
            Thread.Sleep(500);
            blobPropertiesResponse = await targetBlob.GetPropertiesAsync();
        }

        if (blobPropertiesResponse.Value.CopyStatus != Azure.Storage.Blobs.Models.CopyStatus.Success)
        {
            throw new Exception("Copy failed: " + copyInformation.Value.CopyStatus);
        }
}

-Sean

@WillRock19
Copy link
Author

Hi @seanmcc-msft , how are you?

I think we might need to re-open this issue. The solution that you've proposed does not seems to work, since everytime I'm calling the GetProperties the resulted blobPropertiesResponse still have it's CopyStatus with the value Pending. Here is my code:

        public virtual void CopyFromBlobNew(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
        {
            var sourceContainer = GetContainerNew(sourceConnectionString, sourceContainerName);
            var sourceBlob = sourceContainer.GetBlobClient(sourceBlobName);
            
            var targetContainer = GetContainerNew(targetConnectionString, targetContainerName);
            var targetBlob = targetContainer.GetBlobClient(targetBlobName);

            if (!sourceBlob.Exists())
                throw new RequestFailedException($"A copy blob operation was requested, but the source blob {sourceBlobName} does not exist!");

            targetBlob.SyncCopyFromUri(sourceBlob.Uri);
            var blobPropertiesResponse = targetBlob.GetProperties();

            while (blobPropertiesResponse.Value.CopyStatus == CopyStatus.Pending) 
            {
                Thread.Sleep(500);
                blobPropertiesResponse = targetBlob.GetProperties();
            }

            if (blobPropertiesResponse.Value.CopyStatus != CopyStatus.Success)
            {
                throw new Exception("Copy failed. The resulted status is: " + blobPropertiesResponse.Value.CopyStatus);
            }
        }

I've post the synchronous version that I need to use, but I've tried the asynchronous version you've post it and it never comes out from the while statement (while debugging, I've noticed the blobPropertiesResponse.Value.CopyStatus never change from Pending, doesn't matter how many times I call the targetBlob.GetProperties()).

@WillRock19
Copy link
Author

Hi @seanmcc-msft, any updates on this?

1 similar comment
@WillRock19
Copy link
Author

Hi @seanmcc-msft, any updates on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

3 participants