Azure / Azure/azure-functions-core-tools

Intermittent Error when starting functions app

Open
#3,455 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

Hi all,

We've been getting an intermittent error that prevents us from moving forward at all.

```bash
Starting the listener for prefix='', monitoredContainer='CONTAINER_NAME', monitoredDatabase='DB_NAME', leaseContainer='leases', leaseDatabase='DB_NAME', functionId='Host.Functions.FUNCTION_NAME' failed. Exception: System.InvalidOperationException: This builder instance has already been used to build a processor. Create a new instance to build another.
[2023-09-14T12:05:56.295Z] at Microsoft.Azure.Cosmos.ChangeFeedProcessorBuilder.Build()
[2023-09-14T12:05:56.296Z] at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerListener`1.StartProcessorAsync() in D:\a\_work\1\s\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerListener.cs:line 140
[2023-09-14T12:05:56.296Z] at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerListener`1.StartAsync(CancellationToken cancellationToken) in D:\a\_work\1\s\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerListener.cs:line 96.
[2023-09-14T12:05:56.297Z] The listener for function 'Functions.FUNCTION_NAME' was unable to start.
[2023-09-14T12:05:56.297Z] The listener for function 'Functions.FUNCTION_NAME' was unable to start. Microsoft.Azure.Cosmos.Client: This builder instance has already been used to build a processor. Create a new instance to build another.
````

We've tried countless things to attempt to fix this but it seems the only way we can get around this at the moment is to uninstall the Azure Cosmos DB emulator / remove `CosmosDBEmulator` folder from `%localappdata%` and reinstall everything... Even that sometimes does not work. There must be something simple we're missing here. Any pointers as to how we can fix this would be greatly appreciated.

Cheers,

Kyle

Contributor guide

Open the contributing guide

Research direction

Start by reading WebJobs.Extensions.CosmosDB/Trigger/CosmosDBTriggerListener.cs around StartProcessorAsync at line 140 and StartAsync at line 96. Reproduce the intermittent startup failure involving the CosmosDB emulator and ChangeFeedProcessorBuilder.Build(). Done means identifying the cause and establishing a reliable fix or reproduction for the listener startup error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.