Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.49k stars 4.81k forks source link

[BUG] #37264

Open SamDillenio opened 1 year ago

SamDillenio commented 1 year ago

Library name and version

Azure.DigitalTwins.Core version 1.4.0

Describe the bug

We are using the Azure Digital Twins Client to query the ADT. If we add or delete an two nodes with an edge between them, we are encountering an issue. The creation of the first node goes without any problem, but as soon as we try to add a relationship to the newly created node, it sometimes fails with the error that the twin does not exist. The same goes for deleting a twin. We first delete all the relationships of the twin and then delete the twin itself. We sometimes receive this error: {"error":{"code":"RelationshipsNotDeleted","message":"Twin has active relationships. Cannot delete a twin unless all the relationships are deleted. Please ensure that the active relationships on the twin are deleted. See section on retrieving relationships https://aka.ms/adtv2twins."}}

This does not happen when we use the CLI for the same scenario. How can we solve this?

Expected behavior

When the "async" calls return, we can be sure that the following call encounters a state of the DT that resambles the calls.

Actual behavior

The DT behaves "evantually consistant".

Reproduction Steps

var relationships = _digitalTwinsClient.GetRelationshipsAsync<BasicRelationship>(id.ToString(), cancellationToken: cancellationToken);
await foreach (var relationship in relationships)
{
    var relationshipResult =  await _digitalTwinsClient.DeleteRelationshipAsync(id.ToString(), relationship.Id,
        cancellationToken: cancellationToken);
    if (relationshipResult.IsError)
    {
        _logger.LogError(
            "Something went wrong while deleting twin relationship {@TwinId} {@RelationshipId} {@Error}", id,
            relationship.Id, relationshipResult.ReasonPhrase);
    }
}

await _digitalTwinsClient.DeleteDigitalTwinAsync(id.ToString(), cancellationToken: cancellationToken); // => fails from time to time with error mentioned in description.

Environment

No response

github-actions[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

Adding Service team to look into this.

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @johngallardo @efriesner @abhinav-ghai @Aashish93-stack @sjiherzig @Satya-Kolluri.

jaslawinMs commented 1 year ago

I did not find any anomaly so far. If the issue is persistent, please create a ticket on the Azure Portal with more details.