Skip to content

Avoid serializing inline Azure Storage queue messages twice - #1380

Open
berndverst wants to merge 2 commits into
mainfrom
berndverst-avoid-duplicate-queue-serialization
Open

Avoid serializing inline Azure Storage queue messages twice#1380
berndverst wants to merge 2 commits into
mainfrom
berndverst-avoid-duplicate-queue-serialization

Conversation

@berndverst

Copy link
Copy Markdown
Member

Summary

  • reuse the MessageData JSON already produced for the UTF-8 size check when a queue message stays inline
  • verify byte-for-byte inline payload equivalence with a custom type binder in both UseDataContractSerialization modes
  • cover the exact 45 KiB inline boundary and the above-threshold blob payload and queue wrapper

Backward compatibility

The initial serialization already determines both the queue payload size and the inline/blob decision. TotalMessageSizeBytes is internal and is not a data member, so returning that existing JSON on the inline path is byte-for-byte equivalent to the previous second serialization. The size threshold, serializer configuration, public APIs, blob upload content, and blob-reference wrapper serialization are unchanged.

Testing

  • dotnet test Test\DurableTask.AzureStorage.Tests\DurableTask.AzureStorage.Tests.csproj --framework net8.0 --filter "FullyQualifiedName~DurableTask.AzureStorage.Tests.MessageManagerTests"
  • dotnet test Test\DurableTask.AzureStorage.Tests\DurableTask.AzureStorage.Tests.csproj --framework net48 --filter "FullyQualifiedName~DurableTask.AzureStorage.Tests.MessageManagerTests"

Fixes #1378

Bernd Verst added 2 commits July 27, 2026 13:38
Reuse the MessageData JSON already produced for size selection when the payload remains inline. Add exact wire-equivalence and threshold-path regression coverage for both serialization modes and a custom binder.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9509e194-db0b-4024-b7b0-26481278e0db
Verify exact inline payload equivalence, single-pass custom binder behavior, and the inline/blob boundary for both data-contract serialization modes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9509e194-db0b-4024-b7b0-26481278e0db
Copilot AI review requested due to automatic review settings July 27, 2026 20:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes a redundant JSON serialization on the common inline-queue-message path in MessageManager.SerializeMessageDataAsync, reusing the already-produced JSON payload that was generated for the UTF-8 size check. It adds regression tests to assert byte-for-byte equivalence with the prior “serialize twice” behavior (including custom type binder behavior and both UseDataContractSerialization modes), and to validate behavior at the exact 45 KiB inline threshold and just above it (blob offload + wrapper).

Changes:

  • Reuse the initial rawContent JSON string for inline queue payloads instead of serializing MessageData a second time.
  • Add tests validating inline payload equivalence (including custom binder behavior) in both UseDataContractSerialization modes.
  • Add boundary tests covering the exact 45 KiB inline cutoff and the above-threshold blob-wrapper path (including verifying stored blob content).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/DurableTask.AzureStorage/MessageManager.cs Avoids duplicate serialization by returning the already-generated rawContent for inline messages.
test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs Adds regression coverage for inline payload equivalence and for inline/blob behavior at and above the 45 KiB threshold.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid serializing inline Azure Storage queue messages twice

2 participants