question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FeedPollDelay in ChangeFeedProcessorOptions is not respected

See original GitHub issue

Hello everybody,

Describe the bug When FeedPollDelay in CosmosDBTrigger is used (which uses ChangeFeedProcessorOptions) delay is not respected by the change feed mechanism. Calls to the leases collections are made every few seconds.

To Reproduce ChangeFeedProcessorOptions looks as follows:

    public class Func
    {
        public const int FiveMinutesInMiliseconds = 300000;

        [FunctionName("Func")]
        public async Task Run([CosmosDBTrigger(
                databaseName: "databaseName",
                collectionName: "collectionname",
                ConnectionStringSetting = "COSMOSDB_CONNECTION_STRING",
                LeaseCollectionName = "leases",
                CreateLeaseCollectionIfNotExists = true,
                FeedPollDelay = FiveMinutesInMiliseconds)]

In the Azure Func option I see that option is set correctly: image

There were no runs of the function between 9:15 and 9:40: image

but then in CosmosDB Logs I see that the feed mechanism runs every single second image

I tried to clean lease collection, stop and start a function - nothing helped.

Expected behavior A single function call to the leases collection every 5 minutes.

Actual behavior A lot of calls to the leases collection.

Environment summary ActivityId to track function run - 6f6d4528-86fa-404a-9a34-7f0a9afc6fdf Time when happened - 2021-01-19T09:22:32.782Z

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Jan 25, 2021

@rmaziarka

I do not have access to the Consumption Plan details and internal workings, what I am saying is that, if you are on Consumption Plan, then I know the Functions runtime checks the estimation and know if they need to scale up/down. If there are no more events in your Change Feed for more than 5-10 minutes, Consumption Plan scales down and shuts down all instances. But periodically (I have no clue how often, it could be every 10 seconds) they would use the Estimator APIs, to know if there are any new changes and “wake up” instances to process them, this is not a hunch, this actually happens, so it could be very well the source of these queries. All this logic is completely external to Cosmos DB or the Cosmos DB Trigger, so there is nothing you can configure as far as I know (you could ask the Functions team through a support ticket maybe if the period they use to check is configurable). My only hunch based on the screenshot you pasted is the User Agent. At the end, it says changefeed-2.2.1, meaning the source is using the Change Feed Processor nuget 2.2.1, in your Function App project, you probably have the Cosmos DB extension nuget, which has a dependency on the CFP nuget, if your version does not match (for example, yours is higher), then it would confirm the suspicion that it’s coming from there.

Regarding your second question, all those docs are for the Change Feed Processor, not related to Azure Functions Cosmos DB Trigger. Consumption Plan uses the CFP nuget and this API as far as I know:

If your intent is to check if it’s the same query, you could do the same from a console app.

1reaction
ealsurcommented, Jan 19, 2021

@rmaziarka This is the wrong repo, don’t you mean to send this to the Functions repo? https://github.com/Azure/azure-webjobs-sdk-extensions

In any case, this is not a bug and that setting does not measure the calls to the Leases collection.

The leases collection is used to store state. State is updated frequently, whenever your code finishes processing some changes, and periodically to refresh ownership of the leases by the current instance.

The FeedPollDelay affects Change Feed requests to the Monitored Collection (doesn’t affect any interaction with the leases collection). And only applies when the Change Feed is checked and there are no changes. See the official docs: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-trigger?tabs=csharp#configuration

image

For more details on the Change Feed Processor see: https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed-processor

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Feed Processor Lib does not honour ...
FeedPollDelay is used when the Change Feed Processor reads the Change Feed and finds no new changes, not in-between each batch.
Read more >
ChangeFeedProcessorOptions Class
Options to control various aspects of partition distribution happening within Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessor instance.
Read more >
Azure CosmosDB - Apache Camel
DEFAULT value is false indicating this is opt in feature, by default no telemetry ... 60 seconds feed poll delay: 5 seconds maximum...
Read more >
Index (Azure SDK for Java Reference Documentation)
Bounded Staleness guarantees that reads are not too out-of-date. ... ChangeFeedProcessorOptions() - Constructor for class ... Default feed poll delay.
Read more >
Index (Azure SDK for Java Reference ... - javadoc.io
Gets the paths that are not indexed. getFeedPollDelay() - Method in class com.azure.cosmos.models.ChangeFeedProcessorOptions. Gets the delay in between polling ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found