Skip to content

Commit 672bddf

Browse files
authored
Update etag reset logic in the checkpoint store (Azure#48244)
1 parent 51cd5fb commit 672bddf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobCheckpointStoreInternal.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,11 @@ public override async Task<IEnumerable<EventProcessorPartitionOwnership>> ClaimO
223223
{
224224
// This is an unlikely corner case that indicates that the blob was unexpectedly deleted while the
225225
// processor is running. Attempt to recover by resetting the ETag and considering it an upload scenario
226-
// to be handled by the next block.
226+
// to be handled by the next block. Additionally clear the IfMatch to ensure next block does not have
227+
// an outdated ETag.
227228

228229
ownership.Version = null;
230+
blobRequestConditions.IfMatch = null;
229231
}
230232
}
231233

sdk/eventhub/Azure.Messaging.EventHubs.Shared/tests/BlobCheckpointStore/BlobsCheckpointStoreInternalTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,11 @@ public async Task ClaimOwnershipCompensatesWhenABlobIsDeleted()
309309
setMetadataCalled = true;
310310
};
311311

312-
client.UploadAsyncCallback = (_, _, _, _, _, _, _, _) =>
312+
client.UploadAsyncCallback = (_, _, _, conditions, _, _, _, _) =>
313313
{
314314
uploadBlobCalled = true;
315+
Assert.That(conditions.IfNoneMatch, Is.EqualTo(new ETag("*")), "The IfNoneMatch condition should be set.");
316+
Assert.That(conditions.IfMatch, Is.Null, "The IfMatch condition should be null.");
315317
};
316318
});
317319

0 commit comments

Comments
 (0)