We have our custom Change Feed processor deployed in single Region in AKS with 5 instances. Things were always running in single region fine. (Please note that each pod instance (feed processor) is assigned a unique [.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)
- WestUS AKS Cluster = 5 pods (5 feed processor with each unique instance name)
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).
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.
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"