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

Fix serialize-messages for Akka.Cluster and Akka.Remote #3725

Conversation

Aaronontheweb
Copy link
Member

Working on fixing #3724

@Aaronontheweb
Copy link
Member Author

Reproduction spec failed on both Windows and Linux, as is expected.

Copy link
Member Author

@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.

Reviewed my own changes for the sake of clarification.

{
// wait for a singleton cluster to fully form and publish a member up event
_cluster.Join(_selfAddress);
var up = ExpectMsg<ClusterEvent.MemberUp>();
Copy link
Member Author

Choose a reason for hiding this comment

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

The test case here is simple: test that end-to-end, the Akka.Cluster self-join process works and all manner of internal event publication goes off without a hitch. Caught two different major serialization errors with this and fixed both.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the MemberUp event makes it all the way to this actor, we can safely assume that the messages necessary to run Akka.Cluster's internals made it intact.

/// <see cref="INoSerializationVerificationNeeded"/> is not explicitly used on the JVM,
/// but without it we run into serialization issues via https://github.com/akkadotnet/akka.net/issues/3724
/// </remarks>
private interface IPublishMessage : INoSerializationVerificationNeeded { }
Copy link
Member Author

Choose a reason for hiding this comment

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

First fix: made it so IPublishMessage doesn't get checked by akka.actor.serialize-messages - did this because designating a single Gossip class constructor with JsonConstructor wasn't going to work due to the fact that we make use of all three different constructors in different situations. The JVM gets away with this by using the built-in Serializable trait in Scala, which is roughly equivalent to our binary formatter, which .NET no longer has in .NET Core. So, I figured this would be the best substitute here.

Copy link
Member Author

Choose a reason for hiding this comment

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

/// <param name="status">The status of this member.</param>
/// <param name="roles">The roles for this member. Can be empty.</param>
[JsonConstructor]
internal Member(UniqueAddress uniqueAddress, int upNumber, MemberStatus status, IEnumerable<string> roles)
Copy link
Member Author

Choose a reason for hiding this comment

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

The issue with serializing the Member class is an old, but familiar one: JSON.NET is unable to serialize the System.Collections.Immutable.ImmutableHashSet<string> taken for the roles parameter on the normal constructor this actor uses. Thus, I created a second internal constructor that just takes an IEnumerable<string> instead and marked that as the JsonConstructor - ideally once Hyperion is done we will no longer need this.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review February 26, 2019 22:43
@Aaronontheweb
Copy link
Member Author

Looks like there's still a hard failure on Linux with this.

@Aaronontheweb
Copy link
Member Author

Failed on Windows too - passes on .NET Framework locally for me, but looks like it doesn't for .NET Core.

@Dan-Albrecht
Copy link

I pulled this and it seems to fix my problems in my sample and our actual real code.

@Aaronontheweb
Copy link
Member Author

@Dan-Albrecht my guess is that it's an issue related to the old version of .NET Core we're running on (1.1.) I haven't had a chance to test that just yet as I've been neck-deep in working on another issue for most of this afternoon (#3414) but I have a plan for getting all of these projects moved onto .NET Core 2.2 pronto as part of an upcoming sprint.

Glad to hear the fix is working though - I'll merge this in as part of 1.3.12, somehow :p

@Aaronontheweb Aaronontheweb merged commit 00b73df into akkadotnet:dev Jun 4, 2019
@Aaronontheweb Aaronontheweb deleted the fix-3724-serialize-all-messages-cluster branch June 4, 2019 13:59
madmonkey pushed a commit to madmonkey/akka.net that referenced this pull request Jul 12, 2019
)

close akkadotnet#3724 - provided JSON constructor for Member

disabled serialization verification for internal `PublishChanges`
Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this pull request Jul 30, 2019
)

close akkadotnet#3724 - provided JSON constructor for Member

disabled serialization verification for internal `PublishChanges`
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