Repository navigation
Description
In Exceptionless 6.2.0 (core Exceptionless package), when the server responds 413 (Request Entity Too Large), DefaultEventQueue.ProcessAsync lowers a local batchSize and logs "The event will be retried with a smaller batch size", but it then exits the loop immediately. The next run starts again at SubmissionBatchSize, so the smaller batch is never sent.
Where
- (
Exceptionless.Net/src/Exceptionless/Queue/DefaultEventQueue.cs
Lines 58 to 60 in 5792f00
DateTime maxCreatedDate = DateTime.Now; int batchSize = _config.SubmissionBatchSize; var batch = _storage.GetEventBatch(queueName, batchSize, maxCreatedDate); batchSizeis a local reset to_config.SubmissionBatchSizeon every run) - (413 handling reduces
Exceptionless.Net/src/Exceptionless/Queue/DefaultEventQueue.cs
Lines 86 to 93 in 5792f00
} else if (response.RequestEntityTooLarge) { if (batchSize > 1) { _log.Error(typeof(DefaultEventQueue), "Event submission discarded for being too large. The event will be retried with a smaller batch size."); batchSize = Math.Max(1, (int)Math.Round(batchSize / 1.5d, 0)); deleteBatch = false; } else { _log.Error(typeof(DefaultEventQueue), "Event submission discarded for being too large. The event will not be submitted."); } batchSizeand setsdeleteBatch = false) - (
Exceptionless.Net/src/Exceptionless/Queue/DefaultEventQueue.cs
Lines 113 to 121 in 5792f00
if (deleteBatch) _storage.DeleteBatch(batch); else _storage.ReleaseBatch(batch); if (!deleteBatch || IsQueueProcessingSuspended) break; batch = _storage.GetEventBatch(queueName, batchSize, maxCreatedDate); if (!deleteBatch || ...) break;exits before the reduced size is used) - and
public static void CleanupQueueFiles(this IObjectStorage storage, string queueName, TimeSpan? maxAge = null, int? maxAttempts = null) { maxAge = maxAge ?? TimeSpan.FromDays(7); maxAttempts = maxAttempts ?? 3; foreach (var file in storage.GetObjectList(Path.Combine(queueName, "q", "*"), 500).ToList()) { if (DateTime.Now.Subtract(file.Created) > maxAge.Value) storage.DeleteObject(file.Path); if (GetAttempts(file) >= maxAttempts.Value) storage.DeleteObject(file.Path); } (each batch fetch increments the attempt count; files atExceptionless.Net/src/Exceptionless/Extensions/FileStorageExtensions.cs
Lines 96 to 106 in 5792f00
public static IList<Tuple<ObjectInfo, Event>> GetEventBatch(this IObjectStorage storage, string queueName, int batchSize = 50, DateTime? maxCreatedDate = null) { var events = new List<Tuple<ObjectInfo, Event>>(); lock (_lockObject) { foreach (var file in storage.GetQueueFiles(queueName, batchSize * 5, maxCreatedDate)) { if (!storage.LockFile(file)) continue; try { storage.IncrementAttempts(file); } catch {} QueueMaxAttemptsare deleted)
What happens
- A batch of up to 50 events (the default
SubmissionBatchSize) gets a 413. batchSizebecomes 33, the batch is released, and the loop breaks.- About 10 seconds later the timer runs
ProcessAsyncagain, which starts at 50 again and resends the same oversized batch. - Each attempt increments the queued files' attempt counter. Once they reach
QueueMaxAttempts(default 3),CleanupQueueFilesdeletes them.
The result is that every event in the batch is discarded, including events that would have been accepted in a smaller batch. A 413 also does not suspend processing, so the oversized request is resent on every timer tick until the events are deleted.
Expected
After a 413, the queue retries the same events with progressively smaller batches (down to 1). Only an event that is too large on its own is discarded.
Steps to reproduce
- Use a submission client (or a test
ISubmissionClient) that returns 413 for any request with more than N events. - Queue more than N events and call
ProcessQueueAsync()repeatedly. - Every request contains
SubmissionBatchSizeevents. After 3 attempts the events are removed from the queue without being sent.
With the 6.2.0 package, a fake ISubmissionClient that returns 413 for more than 10 events, and 50 queued events, five calls to ProcessQueueAsync() send requests of [50, 50, 50] and then nothing: no smaller batch is ever tried and all 50 events are gone.
Suggested fix
Keep processing in the same run after a 413 (do not break when the batch was released only to shrink it), and/or keep the reduced batch size in a field so later runs use it. Consider not counting a 413 retry against QueueMaxAttempts.
Activity