简体   繁体   English

面临 Azure cosmos 多区域 AKS 更改提要处理器的问题

[英]Facing issue with Azure cosmos change feed processor for Multi region AKS

We have our custom Change Feed processor deployed in single Region in AKS with 5 instances.我们在具有 5 个实例的 AKS 中的单个区域中部署了自定义更改源处理器。 Things were always running in single region fine.事情总是在单个区域运行良好。 (Please note that each pod instance (feed processor) is assigned a unique [.WithInstanceName(new GUID)]. (请注意,每个 pod 实例(提要处理器)都分配有一个唯一的 [.WithInstanceName(new GUID)]。

We recently moving to a multi region setup as following:我们最近转向多区域设置,如下所示:

  • EastUS AKS Cluster = 5 pods (5 feed processor with each unique instance name) EastUS AKS 集群 = 5 个 pod(5 个 feed 处理器,每个实例名称都是唯一的)
  • WestUS AKS Cluster = 5 pods (5 feed processor with each unique instance name) WestUS AKS 集群 = 5 个 pod(5 个 feed 处理器,每个实例名称都是唯一的)

Now with the above setup, the result is not very consistent as sometimes after the AKS service deployment our feedprocessor stops recieving the events for some of the collections).现在使用上述设置,结果不是很一致,因为有时在部署 AKS 服务后,我们的 feedprocessor 停止接收某些集合的事件)。

To fix this we need to eventually delete the lease collection and then everything starts working again.为了解决这个问题,我们需要最终删除租约集合,然后一切都会重新开始。

We cannot go live with the above workaround, so need help to resolve the issue.我们不能 go 使用上述解决方法,因此需要帮助来解决问题。

Here is the code snippet:这是代码片段:

Container leaseContainer = cosmosClient.GetContainer(databaseName, leaseContainerName);
            changeFeedProcessor = cosmosClient.GetContainer(databaseName, sourceContainerName)
                .GetChangeFeedProcessorBuilder(processorName: sourceContainerName, async (IReadOnlyCollection<TContainer> changes, CancellationToken cancellationToken) => await onChangesDelegate(changes, cancellationToken))
                    .WithInstanceName($"{Guid.NewGuid()}")
                    .WithLeaseContainer(leaseContainer)
                    .Build();

where leaseContainerName = "container-lease"其中 leaseContainerName = "container-lease"

The problem is that you are mixing instances.问题是您正在混合实例。 If you want each region to work independently (the same document change go to both groups of processors independently), set a different processorName .如果你希望每个区域独立工作(同一个文档将 go 更改为独立的两组处理器),请设置不同的processorName

When you define a cluster of machines with a particular processorName , lease and monitored containers, you define a Deployment Unit .当您定义具有特定processorName 、租约和受监控容器的机器集群时,您定义了一个Deployment Unit The change feed events are distributed across those machines.更改源事件分布在这些机器上。

If you deploy 2 clusters but with the same values, then the 10 pods are now the same Deployment Unit, so the changes are spread across the 10 pods, meaning now that a particular change will land in 1 of the instances on one of the region but the other region will not see it.如果您部署 2 个集群但具有相同的值,那么这 10 个 pod 现在是相同的部署单元,因此更改分布在 10 个 pod 中,这意味着现在特定更改将落在其中一个区域的 1 个实例中但其他地区将看不到它。

You could set as processorName the region name for example:您可以将区域名称设置为processorName ,例如:

Container leaseContainer = cosmosClient.GetContainer(databaseName, leaseContainerName);
            changeFeedProcessor = cosmosClient.GetContainer(databaseName, sourceContainerName)
                .GetChangeFeedProcessorBuilder(processorName: regionName, async (IReadOnlyCollection<TContainer> changes, CancellationToken cancellationToken) => await onChangesDelegate(changes, cancellationToken))
                    .WithInstanceName($"{Guid.NewGuid()}")
                    .WithLeaseContainer(leaseContainer)
                    .Build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM