Skip to content

Commit

Permalink
Do not reject rejection messages locally. Drop them instead (#6525)
Browse files Browse the repository at this point in the history
(cherry picked from commit 576fb55)
  • Loading branch information
benjaminpetit authored and sergeybykov committed May 18, 2020
1 parent c58d875 commit 92caec1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Orleans.Runtime/Messaging/MessageCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,20 @@ public bool TrySendLocal(Message message)
internal void SendRejection(Message msg, Message.RejectionTypes rejectionType, string reason)
{
MessagingStatisticsGroup.OnRejectedMessage(msg);
if (string.IsNullOrEmpty(reason)) reason = string.Format("Rejection from silo {0} - Unknown reason.", MyAddress);
Message error = this.messageFactory.CreateRejectionResponse(msg, rejectionType, reason);
// rejection msgs are always originated in the local silo, they are never remote.
this.OnReceivedMessage(error);

if (msg.Direction == Message.Directions.Response && msg.Result == Message.ResponseTypes.Rejection)
{
// Do not send reject a rejection locally, it will create a stack overflow
MessagingStatisticsGroup.OnDroppedSentMessage(msg);
if (this.log.IsEnabled(LogLevel.Debug)) log.Debug("Dropping rejection {msg}", msg);
}
else
{
if (string.IsNullOrEmpty(reason)) reason = $"Rejection from silo {this.MyAddress} - Unknown reason.";
var error = this.messageFactory.CreateRejectionResponse(msg, rejectionType, reason);
// rejection msgs are always originated in the local silo, they are never remote.
this.OnReceivedMessage(error);
}
}

public void RegisterLocalMessageHandler(IncomingMessageHandler handler)
Expand Down

0 comments on commit 92caec1

Please sign in to comment.