Skip to content

Commit 4a275fb

Browse files
authored
Persist deduplicated message positions so they are always cleared (#176)
When ProcessMessages drops a message as a duplicate (by idempotency key), stage its position into _deliveredPositions and persist it to the DeliveredPositionsId effect immediately, rather than relying on an immediate per-position store delete. Previously the dedup branch added the position to the in-memory set only when piggybacking on a real delivery's effect upsert. If no delivery followed (all-duplicate batch, no matching subscription, or the flow suspended/completed first) the position was never written to the effect, so AfterFlush never cleared it from the store and a crash could not replay it. Persisting at stage time routes dedup cleanup through the same batched, crash-safe drain path as real deliveries. The write is taken under _lock to match the DeliverMessages access.
1 parent 34e5e3f commit 4a275fb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Core/Cleipnir.ResilientFunctions/Queuing/QueueManager.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,11 @@ private async Task ProcessMessages(IReadOnlyList<StoredMessage> messages)
227227

228228
if (idempotencyKey != null && !_idempotencyKeys.Add(idempotencyKey, position))
229229
{
230-
await _messageClearer.Clear([position]);
230+
lock (_lock)
231+
{
232+
_deliveredPositions.Add(position);
233+
_effect.FlushlessUpsert(DeliveredPositionsId, _deliveredPositions.ToList(), alias: null);
234+
}
231235
continue;
232236
}
233237

0 commit comments

Comments
 (0)