Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore duplicate client requests #379

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/DurableTask.Netherite/PartitionState/PrefetchState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,23 @@ public override void Process(WaitRequestReceived waitRequestEvent, EffectTracker
void ProcessClientRequestEventWithPrefetch(ClientRequestEventWithPrefetch clientRequestEvent, EffectTracker effects)
{
if (clientRequestEvent.Phase == ClientRequestEventWithPrefetch.ProcessingPhase.Read)
{
this.Partition.Assert(!this.PendingPrefetches.ContainsKey(clientRequestEvent.EventIdString), "PendingPrefetches.ContainsKey(clientRequestEvent.EventIdString)");

// Issue a read request that fetches the instance state.
// We have to buffer this request in the pending list so we can recover it.
{
// It's possible for EventHubs to duplicate client-to-partition events. Therefore, we perform a best-effort
// de-duplication of EH messages. For more details, see: https://github.com/microsoft/durabletask-netherite/pull/379
if (!this.PendingPrefetches.ContainsKey(clientRequestEvent.EventIdString))
{
// Issue a read request that fetches the instance state.
// We buffer this request in the pending list so we can recover it, and can filter duplicates
// (as long as the duplicates appear soon after the original)

this.PendingPrefetches.Add(clientRequestEvent.EventIdString, clientRequestEvent);
this.PendingPrefetches.Add(clientRequestEvent.EventIdString, clientRequestEvent);
}
else
{
// this is a duplicate. Ignore it.
effects.EventTraceHelper?.TraceEventProcessingWarning($"Dropped duplicate client request {clientRequestEvent} id={clientRequestEvent.EventIdString}");
return;
}
}
else
{
Expand Down