Azure / Azure/azure-functions-host

Need help understanding why function with event hub trigger periodically reprocesses data

Open
#7,227 6 comments 1 reaction 0 assignees View on GitHub
needs-investigation
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

We are in the process of expanding our Azure Function usage and lately I have seen an issue where our Event Hub triggered function seems to reprocess messages. I have not encountered this with any previous testing but now I am starting to see it quite frequently.

For reference, I am getting large spikes of outgoing messages when I view the metrics for the Event Hub:

Screen Shot 2021-03-15 at 10 45 30 PM

Between 3:59 and 4:00, the outgoing message rate spikes up.

Looking at App Insights leading up to this time I see some exceptions which I believe are related to scaling and are normal:

- System.ArgumentOutOfRangeException: Ignoring out of date checkpoint with offset /sequence number because current persisted checkpoint has higher offset /sequence number (Parameter 'offset/sequenceNumber')
- Microsoft.WindowsAzure.Storage.StorageException: The lease ID specified did not match the lease ID for the blob. The lease ID specified did not match the lease ID for the blob.
- Microsoft.WindowsAzure.Storage.StorageException: There is already a lease present.

For some time after 4:00 I see other exceptions related to function timeout and out of memory, but I believe those are the result of my function having to reprocess a large amount of data.

When looking at the traces in App Insights, I see some of the below message leading up to 4:00:

Screen Shot 2021-03-15 at 11 07 51 PM

There is only an error message and no exception/stack trace.

#### Investigative information

Please provide the following:

(timestamp and invocation id are not for a particular failure, but rather just an example of an execution around the time I started to see problems)

- Timestamp: 2021-03-15T20:57:27.1044292Z
- Function App version: 3.0.15405.0
- Invocation ID: b721d37c-a252-4cdb-a809-f8cda44a922f
- Region: centralus

#### Repro steps

N/A

#### Expected behavior

Function does not reprocess large amounts of data.

#### Actual behavior

Function appears to have reprocessed data.

#### Known workarounds

N/A

#### Related information

Provide any related information

- Using Custom Handlers

Contributor guide

Open the contributing guide

Research direction

Start with the App Insights exceptions and traces around 2021-03-15T20:57:27Z, focusing on the Event Hub trigger, checkpoint and lease messages, scaling, timeouts, and out-of-memory errors. Review the custom handler context and available invocation data; done means identifying a reproducible cause and a verified way to prevent the apparent large-scale reprocessing.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
backend, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.