Skip to content

Commit

Permalink
Merge branch 'CoreHelpers:master' into feature/onlyrowandpartition
Browse files Browse the repository at this point in the history
  • Loading branch information
petero-dk authored Jun 6, 2024
2 parents 4283a29 + 7466947 commit 49a9aa7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
jobs:
build-nuget:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,34 @@ public static async Task<Response<IReadOnlyList<Response>>> SubmitTransactionWit
// check the exception
if (allowAutoCreate && ex.ErrorCode.Equals("TableNotFound"))
{
// try to create the table
await tc.CreateAsync();

// This is a double check pattern to ensure that two independent processes
// who are trying to create the table in parallel do not end up in an unhandled
// situation.
try
{
// try to create the table
await tc.CreateAsync();
}
catch (TableTransactionFailedException doubleCheckEx)
{
// check if we have an errorCode if not the system throws the exception
// to the caller
if (String.IsNullOrEmpty(doubleCheckEx.ErrorCode))
{
ExceptionDispatchInfo.Capture(ex).Throw();
return null;
}

// Every error except the TableAlreadyExists is thrown to the caller but
// in the case the system is trying to create the table in parallel we
// ignore the error and execute the transaction!
if (!doubleCheckEx.ErrorCode.Equals("TableAlreadyExists"))
{
ExceptionDispatchInfo.Capture(ex).Throw();
return null;
}
}

// retry
return await tc.SubmitTransactionAsync(transactionActions, cancellationToken);
Expand Down

0 comments on commit 49a9aa7

Please sign in to comment.