Skip to content

Conversation

maxcherednik
Copy link
Contributor

@maxcherednik maxcherednik commented Jan 18, 2017

The old and new logs are in the issue #2452

@@ -591,7 +591,7 @@ protected override SupervisorStrategy SupervisorStrategy()
{
var causedBy = ia.InnerException == null
? ""
: string.Format("Caused by: [{0}]", ia.InnerException);
: $"Caused by: [{ia.InnerException}]";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the concept of the known issue was here before. If there is inner exception, we print the message and the stack trace. No changes here.

{
// Prepare a Task and pass its completion source to the manager
var statusPromise = new TaskCompletionSource<AssociationHandle>();

manager.Tell(new AssociateUnderlyingRefuseUid(SchemeAugmenter.RemoveScheme(remoteAddress), statusPromise, refuseUid));

return statusPromise.Task.CastTask<AssociationHandle, AkkaProtocolHandle>();
return (AkkaProtocolHandle)await statusPromise.Task;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code is simplified here, cause CastTask generated AggregatedException of AggregatedException of.... so on the higher level there was no way to reliably handle exceptions. I believe this should be relatively safe.

@@ -281,32 +281,36 @@ public HeliosTcpTransport(ActorSystem system, Config config)
/// <param name="remoteAddress">TBD</param>
/// <exception cref="HeliosConnectionException">TBD</exception>
/// <returns>TBD</returns>
protected override Task<AssociationHandle> AssociateInternal(Address remoteAddress)
protected override async Task<AssociationHandle> AssociateInternal(Address remoteAddress)
Copy link
Contributor Author

@maxcherednik maxcherednik Jan 18, 2017

Choose a reason for hiding this comment

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

This is the key change here. I don't think we need to throw some Helios exceptions here, cause no one is waiting them and we are not following the interface - if we know what is happening, we should throw InvalidAssociationException with Human readable message and nothing on the inner exception, if not - like usual - just don't catch it.

/// <param name="localAddress">TBD</param>
/// <param name="remoteAddress">TbD</param>
/// <param name="cause">TBD</param>
/// <param name="disassociateInfo">TBD</param>
public InvalidAssociation(Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
: base(string.Format("Invalid address: {0}", remoteAddress), cause)
public InvalidAssociation(string message, Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hardcoded message removed, parameter added

Copy link
Member

Choose a reason for hiding this comment

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

Could you please add these as constructor overloads, rather than modifying the original constructors? I doubt that anyone is using these public APIs in their own code but for the sake of consistency, let's not modify the public API if we can avoid it.

Copy link
Member

Choose a reason for hiding this comment

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

Hah! These are internal classes. Nevermind!

}
catch (Exception e)
{
return new Status.Failure(e.InnerException);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still get the AggregatedException here because of PipeTo - hence we take the inner exception, which is either InvalidAssociationException or some unhandled exception - in any case we propagate this further.

Copy link
Member

Choose a reason for hiding this comment

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

This change looks good to me... I think TaskScheduler.Default will still get used here, but even if it doesn't I don't think it will matter given how simple the continuation is (object / exception mapping.)

PublishAndThrow(
new EndpointAssociationException(string.Format("Association failed with {0}",
RemoteAddress)), LogLevel.DebugLevel);
if (failure.Cause.InnerException == null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In here there is a mapping from InvalidAssociationException to InvalidAssociation exception. This mapping was here before! Again - no inner exception - situation is under control - we know what is happening.

Everything else mapped and propagated with the original exception inside. Btw old implementation was hiding it.

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.

{
PublishAndThrow(
new EndpointAssociationException(string.Format("Association failed with {0}",
RemoteAddress)), LogLevel.DebugLevel);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we were hiding unhandled exceptions - not cool!

return new Handle(handle.Result);
}, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)
.PipeTo(Self);
AssociateAsync().PipeTo(Self);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same story here - simplification in order to get rid of AggregatedExceptions. I am fully following PipeTo guideline here.

case DisassociateInfo.Shutdown:
throw new ShutDownAssociation(LocalAddress, RemoteAddress, new InvalidAssociationException("The remote system terminated the association because it is shutting down."));
throw new ShutDownAssociation($"The remote system terminated the association because it is shutting down. Shut down address: {RemoteAddress}", LocalAddress, RemoteAddress);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed unnecessary inner exceptions - no one is waiting for them on the higher level, so we were throwing them here for nothing.

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

These changes look excellent. I'm going to review some of the MNTR logs before submitting final approval.

/// <param name="localAddress">TBD</param>
/// <param name="remoteAddress">TbD</param>
/// <param name="cause">TBD</param>
/// <param name="disassociateInfo">TBD</param>
public InvalidAssociation(Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
: base(string.Format("Invalid address: {0}", remoteAddress), cause)
public InvalidAssociation(string message, Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add these as constructor overloads, rather than modifying the original constructors? I doubt that anyone is using these public APIs in their own code but for the sake of consistency, let's not modify the public API if we can avoid it.

/// <param name="localAddress">TBD</param>
/// <param name="remoteAddress">TbD</param>
/// <param name="cause">TBD</param>
/// <param name="disassociateInfo">TBD</param>
public InvalidAssociation(Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
: base(string.Format("Invalid address: {0}", remoteAddress), cause)
public InvalidAssociation(string message, Address localAddress, Address remoteAddress, Exception cause = null, DisassociateInfo? disassociateInfo = null)
Copy link
Member

Choose a reason for hiding this comment

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

Hah! These are internal classes. Nevermind!

}
catch (Exception e)
{
return new Status.Failure(e.InnerException);
Copy link
Member

Choose a reason for hiding this comment

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

This change looks good to me... I think TaskScheduler.Default will still get used here, but even if it doesn't I don't think it will matter given how simple the continuation is (object / exception mapping.)

PublishAndThrow(
new EndpointAssociationException(string.Format("Association failed with {0}",
RemoteAddress)), LogLevel.DebugLevel);
if (failure.Cause.InnerException == null)
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.

var handler = (TcpClientHandler) associate.Pipeline.Last();
return await handler.StatusFuture;
}
catch (AggregateException e) when (e.InnerException is ConnectException)
Copy link
Member

Choose a reason for hiding this comment

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

I had no idea you could even do this with when.... that's awesome.

@Aaronontheweb
Copy link
Member

Just finished reviewing some of the logs from MNTR specs that kill off lots of nodes, and the logs are much much cleaner. This is excellent work. Thank you!

@Aaronontheweb Aaronontheweb merged commit 2928795 into akkadotnet:dev Jan 18, 2017
@maxcherednik maxcherednik deleted the akka_remote_logging branch January 19, 2017 06:14
@Aaronontheweb Aaronontheweb modified the milestone: 1.1.3 Jan 20, 2017
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.

2 participants