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

Cap retries to 8000 surrogate id errors #4801

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ internal async Task<IReadOnlyList<string>> ImportResourcesAsync(IReadOnlyList<Im

int GetMaxRetries(IReadOnlyList<ImportResource> resources, ImportMode importMode)
{
return importMode == ImportMode.IncrementalLoad && resources.Any(_ => _.KeepLastUpdated) ? 80000 / resources.Count : 30; // 80K is id sequence rollover
return importMode == ImportMode.IncrementalLoad && resources.Any(_ => _.KeepLastUpdated) ? Math.Min(8000, 80000 / resources.Count) : 30; // 80K is id sequence rollover
}

List<string> GetErrors(IReadOnlyCollection<ImportResource> dups, IReadOnlyCollection<ImportResource> conflicts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ EXECUTE dbo.MergeResourcesCommitTransaction @TransactionId
public async Task GivenIncrementalLoad_80KSurrogateIds_BadRequestIsReturned()
{
var ndJson = new StringBuilder();
for (int i = 0; i < 80001; i++)
for (int i = 0; i < 79001; i++)
{
var id = Guid.NewGuid().ToString("N");
var str = CreateTestPatient(id, DateTimeOffset.Parse("1900-01-01Z00:00")); // make sure this date is not used by other tests.
Expand All @@ -227,7 +227,21 @@ public async Task GivenIncrementalLoad_80KSurrogateIds_BadRequestIsReturned()
var location = (await ImportTestHelper.UploadFileAsync(ndJson.ToString(), _fixture.StorageAccount)).location;
var request = CreateImportRequest(location, ImportMode.IncrementalLoad);
var checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request);
var message = await ImportWaitAsync(checkLocation, false);
await ImportWaitAsync(checkLocation, true);

ndJson = new StringBuilder();
for (int i = 0; i < 1000; i++) // load violators in nlarge batch to avoid large number of retries
{
var id = Guid.NewGuid().ToString("N");
var str = CreateTestPatient(id, DateTimeOffset.Parse("1900-01-01Z00:00")); // make sure this date is not used by other tests.
ndJson.Append(str);
}

location = (await ImportTestHelper.UploadFileAsync(ndJson.ToString(), _fixture.StorageAccount)).location;
request = CreateImportRequest(location, ImportMode.IncrementalLoad);
checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request);
var message = await ImportWaitAsync(checkLocation, true);

Assert.Equal(HttpStatusCode.BadRequest, message.StatusCode);
Assert.Contains(ImportProcessingJob.SurrogateIdsErrorMessage, await message.Content.ReadAsStringAsync());
}
Expand Down
Loading