Azure 事件中心 - IEventProcessor 的 CloseAsync 中的 LeaseLostException

Azure Event Hubs - LeaseLostException in CloseAsync of IEventProcessor

我们 IEventProcessor 中的 CloseAsync(PartitionContext, CloseReason) 方法有以下实现:

public async Task CloseAsync(PartitionContext context, CloseReason reason)
{
    // log reason and partition id

    if (reason == CloseReason.Shutdown)
    {
        // log shutdown event
        await context.CheckpointAsync();
    }
}

我们知道 LeaseLost 异常在这个方法中很好,我们看到了这些线程:

它曾经在处理器关闭时在某些调用中失败,但在其他调用中成功。 最近,我们注意到当原因是 CloseReason.Shutdown 并且总是出现完全相同的异常 LeaseLostException 时,它在对 CloseAsync() 的所有调用中始终失败。这是完整的异常消息和堆栈跟踪:

Message: 'The lease ID specified did not match the lease ID for the blob.'

StackTrace:

at Microsoft.Azure.EventHubs.Processor.AzureStorageCheckpointLeaseManager.UpdateLeaseCoreAsync(AzureBlobLease lease) at Microsoft.Azure.EventHubs.Processor.AzureStorageCheckpointLeaseManager.UpdateCheckpointAsync(Lease lease, Checkpoint checkpoint) at Microsoft.Azure.EventHubs.Processor.PartitionContext.PersistCheckpointAsync(Checkpoint checkpoint) at CloseAsync(PartitionContext context, CloseReason reason) at Microsoft.Azure.EventHubs.Processor.PartitionPump.CloseAsync(CloseReason reason)

我们正在使用 Microsoft.Azure.EventHubs v4.3.0 和 Microsoft.Azure.EventHubs.Processor v4.3.0

我们担心在这种情况下,不会写入任何检查点,并且在处理器重新启动时,由于无法保存最近的检查点位置,将会出现大量重复项。 有没有办法了解导致失败的原因以及如何修复它们?

正如 Jesse Squire 在评论中提到的那样。 这是由于 Microsoft.Azure.EventHubs.Processor 的 v4.3.0 中的 bug。 它已修复 here,但尚未发布。

抱歉给您带来麻烦。修复将在本周的 4.3.1 版本中发布。