Repository navigation
Intermittent ArgumentException in WireFormatting.WriteLongstr during BasicPublishAsync header serialization (RabbitMQ.Client 7.2.0) #1918
Replies: 5 comments 5 replies
|
@tiagopinaskyline we need an executable way to reproduce this behavior at least some of the time. |
|
I traced the full serialization path from The exception occurs when The A few follow-up questions:
We still need an executable reproducer to confirm. As @michaelklishin noted, without one it's difficult to go further. |
|
Thanks for the detailed analysis. I ran a number of follow-up tests on my side and can now answer your questions more precisely.
The flow is:
I serialize publishes through a SemaphoreSlim in my session layer, and publishes are awaited sequentially in a foreach, so there is only one in-flight publish at a time for this session/channel. I also added an extra defensive step immediately before BasicPublishAsync:
So the object passed into BasicPublishAsync is a copied, read-only headers dictionary. That probe succeeds consistently. In the latest failing run it logged:
So the exact same BasicProperties object can self-serialize successfully immediately before the publish call, but BasicPublishAsync still fails right afterward with: WriteTable -> WriteFieldValue -> WriteLongstr -> UTF8Encoding.GetBytes This materially weakens the hypothesis that my code is mutating Headers before publish.
The exception still reproduces. So at this point the failure is reproducible even:
Headers were:
The BasicProperties self-serialization probe passed. required=309, written=309 log appears immediately before the BasicPublishAsync failure. I'm attaching the producer file. Thank you |
|
Thank you for the detailed follow-up and diagnostics. Your testing has ruled out the common causes (shared The fact that your self-serialization test passes immediately before the failing Your test: Allocates a small 309-byte array and calls Inside With your 25 MB body size, the rented array lands on the Large Object Heap. On .NET Framework 4.8 with the To help narrow this down:
Most importantly, we need a minimal reproducer that we can compile and run to investigate further. Without one, it's difficult to make progress on this issue. |
|
I tested the safe-methods package and the issue still occurs. That suggests the unsafe WriteShortstr / WriteLongstr path is likely not the full root cause. The branch does replace those string writes with safe UTF8.GetBytes(...)-based logic, but the real publish path still uses the same combined framing strategy in SerializeToFrames(...). In our environment, the issue appears to be runtime-sensitive. I could not produce a reliable standalone repro, but in the actual host process the failure correlates with heavy load: 32-bit process, .NET Framework, very large messages, and high CPU usage. Based on that, I think the next step should be to focus less on WriteLongstr in isolation and more on the combined publish/framing path itself. At the moment, I can provide failing logs from the real environment, but I cannot provide a clean standalone repro. The strongest trigger conditions I've seen are large payloads plus host pressure/churn in a 32-bit .NET Framework process. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Hi,
I'm seeing an intermittent client-side exception during 'BasicPublishAsync' in RabbitMQ.Client 7.2.1.
Assembly metadata logged at runtime:
The exception is:
Stack Trace
The failure is intermittent: the same publish path and same header set can succeed many times and then fail.
Diagnostics right before 'BasicPublishAsync':
Logged 'BasicProperties'/headers at failure time:
Details
Does this look like another issue in the header/publish serialization path, or is there any scenario where WriteLongstr can hit this with tiny/stable header values like the above?
Thank you
Reproduction steps
This does not look like a shortstr / 255-byte limit issue. Also, the string values are plain ASCII / UTF-8 encodable. The exception appears to happen while the client is serializing the outgoing header/properties frame, before anything broker-side could reject the publish
Expected behavior
I’m opening this separately from #907 because that issue appears to be about shortstr length handling, while this failure is in WriteLongstr while serializing a header table.
All reactions