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

Propagate exceptions during message body deserialization #2364

Merged
merged 2 commits into from Nov 15, 2016

Conversation

ReubenBond
Copy link
Member

In some cases, a message body cannot be deserialized and so the message is dropped without notifying the caller. The call will eventually fail with a timeout exception but with no indication of why that timeout occurred.

This PR propagates body deserialization exceptions back to the caller.

Instead of deserializing the body in the Message constructor, this PR moves the assignment of the body to a separate method. This way, the partially-deserialized message is still valid and has correctly deserialized headers, so a failure response can be constructed.

@gabikliot
Copy link
Contributor

Are u sure? I remember very clearly this particular case of body can't deserialze and I fixed it to send exception. It was fixed and correct for years. If this is broken now, it's a regression introduced recently.

@ReubenBond
Copy link
Member Author

ReubenBond commented Oct 29, 2016

@gabikliot there are two cases:

  • One where deserialization is deferred until it's running in the context of an activation which is fine: we get msg.BodyObject at which point deserialization occurs and the exception is thrown and handled properly. This happens when messages are deserialized in the by the gateway receiver.
  • The other case (which this fixes) in inter-silo communication where we eagerly deserialize the body so that we can immediately reclaim the underlying byte arrays.

This is a bug which I've known has existed for some time, but never pinned it down until now.

BTW, there's still a bug: when RequestContext contains an undeserializable object, this will still fail with a timeout because RequestContext is stored in the message headers.

EDIT: I might be wrong about my analyses there, but the bug is rather obvious in the TryDecodeMessage code.

@gabikliot
Copy link
Contributor

I see.
It used to be that we only ever had the first case. Then the 2nd case was added, about a year - year and a half ago (@ jason-bragg). Very dangerous to have the main code path be split like this.

@ReubenBond
Copy link
Member Author

@dotnet-bot test this please

@sergeybykov sergeybykov modified the milestone: 1.4.0 Nov 3, 2016
@ReubenBond
Copy link
Member Author

ReubenBond commented Nov 14, 2016

@gabikliot I'm assuming that this was done in the name of performance, but I certainly agree that the added complexity adds a bit of risk - it wasn't obvious to me why this was happening at first.

Is anyone available to review the fix?

@gabikliot
Copy link
Contributor

I will try to take a look, but I really think this should be reviewed by @jason-bragg .

Copy link
Contributor

@jason-bragg jason-bragg left a comment

Choose a reason for hiding this comment

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

Looks good. This code path is rather fragile, but it looks like all error cases have been properly handled.

@@ -12,6 +12,8 @@

namespace Orleans.Runtime.Messaging
{
using System.Linq.Expressions;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this used for? We try to avoid linq in this layer due to perf. Not saying to remove this, just don't see where it is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks :)

@jason-bragg jason-bragg merged commit 3484cdf into dotnet:master Nov 15, 2016
@ReubenBond ReubenBond deleted the fix-unreadable-msg-body branch December 7, 2016 22:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants