diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/CHANGELOG.md b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/CHANGELOG.md index f29226a512f2..638d37c73a01 100644 --- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/CHANGELOG.md +++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-08-03) + +### Bugs Fixed + +- Allow some `HttpStatusCode.NotFound` occurrences in `PostLedgerEntryOperation` to account for unexpected loss of session stickiness. These errors may occur when the connected node changes and transactions have not been fully replicated. + ## 1.2.0-beta.1 (Unreleased) ### Features Added diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/assets.json b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/assets.json index 445e1f9bf331..f19574db14f6 100644 --- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/assets.json +++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/confidentialledger/Azure.Security.ConfidentialLedger", - "Tag": "net/confidentialledger/Azure.Security.ConfidentialLedger_48488df791" + "Tag": "net/confidentialledger/Azure.Security.ConfidentialLedger_5657482b45" } diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj index 150fe921ab55..8fc08c597c37 100644 --- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj +++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj @@ -2,7 +2,7 @@ Client SDK for the Azure Confidential Ledger service Azure Confidential Ledger - 1.2.0-beta.1 + 1.2.0 1.1.0 Azure ConfidentialLedger diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs index 372caaefec5e..7e3ce27aa22c 100644 --- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs +++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs @@ -55,12 +55,36 @@ public override Response UpdateStatus(CancellationToken cancellationToken = defa async ValueTask IOperation.UpdateStateAsync(bool async, CancellationToken cancellationToken) { - var statusResponse = async - ? await _client.GetTransactionStatusAsync( - Id, - new RequestContext { CancellationToken = cancellationToken, ErrorOptions = ErrorOptions.NoThrow }) - .ConfigureAwait(false) - : _client.GetTransactionStatus(Id, new RequestContext { CancellationToken = cancellationToken, ErrorOptions = ErrorOptions.NoThrow }); + int retryCount = 0; + Azure.Response statusResponse = null; + while (retryCount < 3) + { + statusResponse = async + ? await _client.GetTransactionStatusAsync( + Id, + new RequestContext { CancellationToken = cancellationToken, ErrorOptions = ErrorOptions.NoThrow }) + .ConfigureAwait(false) + : _client.GetTransactionStatus(Id, new RequestContext { CancellationToken = cancellationToken, ErrorOptions = ErrorOptions.NoThrow }); + + // The transaction may not be found due to unexpected loss of session stickiness. + // This may occur when the connected node changes and transactions have not been fully replicated. + // We will perform retry logic to ensure that we have waited for the transactions to fully replicate before throwing an error. + if (statusResponse.Status == (int)HttpStatusCode.NotFound) + { + ++retryCount; + } + else + { + break; + } + + // Add a 0.5 second delay between retries. + if (async) { + await Task.Delay(500).ConfigureAwait(false); + } else { + Thread.Sleep(500); + } + } if (statusResponse.Status != (int)HttpStatusCode.OK) { @@ -76,6 +100,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella { return OperationState.Success(statusResponse); } + return OperationState.Pending(statusResponse); }