From 3337608a2fe4d925c0117dccc4db8f77349a35be Mon Sep 17 00:00:00 2001 From: Esma <69813504+esmadau@users.noreply.github.com> Date: Thu, 6 Jul 2023 12:22:05 -0700 Subject: [PATCH] allow partitions to lock when joining to delete instance (#2863) ## Description allow partitions to lock when joining to delete instance so we get latest data ## Related issues Addresses [[AB#105059](https://microsofthealth.visualstudio.com/f8da5110-49b1-4e9f-9022-2f58b6124ff9/_workitems/edit/105059)]. ## Testing n/a --- .../Features/Schema/Migrations/42.diff.sql | 2 +- .../Features/Schema/Migrations/42.sql | 2 +- .../Features/Schema/Sql/Sprocs/RetrieveDeletedInstanceV42.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.diff.sql b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.diff.sql index 0fde302139..ba40fd681d 100644 --- a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.diff.sql +++ b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.diff.sql @@ -21,7 +21,7 @@ BEGIN d.OriginalWatermark FROM dbo.DeletedInstance AS d WITH (UPDLOCK, READPAST) INNER JOIN - dbo.Partition AS p WITH (NOLOCK) + dbo.Partition AS p ON p.PartitionKey = d.PartitionKey WHERE RetryCount <= @maxRetries AND CleanupAfter < SYSUTCDATETIME(); diff --git a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.sql b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.sql index 9bc6bf796e..8436e11d41 100644 --- a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.sql +++ b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Migrations/42.sql @@ -2630,7 +2630,7 @@ BEGIN d.OriginalWatermark FROM dbo.DeletedInstance AS d WITH (UPDLOCK, READPAST) INNER JOIN - dbo.Partition AS p WITH (NOLOCK) + dbo.Partition AS p ON p.PartitionKey = d.PartitionKey WHERE RetryCount <= @maxRetries AND CleanupAfter < SYSUTCDATETIME(); diff --git a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Sql/Sprocs/RetrieveDeletedInstanceV42.sql b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Sql/Sprocs/RetrieveDeletedInstanceV42.sql index afe35eb6e4..6dd97138d2 100644 --- a/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Sql/Sprocs/RetrieveDeletedInstanceV42.sql +++ b/src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Sql/Sprocs/RetrieveDeletedInstanceV42.sql @@ -23,7 +23,7 @@ BEGIN SELECT TOP (@count) p.PartitionName, d.PartitionKey, d.StudyInstanceUid, d.SeriesInstanceUid, d.SopInstanceUid, d.Watermark, d.OriginalWatermark FROM dbo.DeletedInstance as d WITH (UPDLOCK, READPAST) - INNER JOIN dbo.Partition as p WITH (NOLOCK) + INNER JOIN dbo.Partition as p ON p.PartitionKey = d.PartitionKey WHERE RetryCount <= @maxRetries AND CleanupAfter < SYSUTCDATETIME()