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

Akka.Cluster.Sharding GetShardRegionStats serialization issue #3830

Closed
Aaronontheweb opened this issue Jun 26, 2019 · 3 comments
Closed

Akka.Cluster.Sharding GetShardRegionStats serialization issue #3830

Aaronontheweb opened this issue Jun 26, 2019 · 3 comments

Comments

@Aaronontheweb
Copy link
Member

Version: Akka.NET v1.4.0 current dev branch

Error occurs when attempting to send a GetClusterShardingStats message from a non-coordinator ShardRegion to the PersistentShardRegion coordinator, in this case via the Petabridge.Cmd.Cluster.Sharding command palette, a deserialization error occurs in JSON.NET when deserializing the ClusterShardingStats response sent back by the coordinator:

ka.tcp://ShardFight@7061a2bcb4e7:5110: Error [Could not convert string 'akka.tcp://ShardFight@8fb41e2d2e27:5110' to dictionary key type 'Akka.Actor.Address'. Create a TypeConverter to convert from the string to the key type object. Path 'Regions['akka.tcp://ShardFight@8fb41e2d2e27:5110']', line 1, position 324.] [   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Akka.Serialization.NewtonSoftJsonSerializer.FromBinary(Byte[] bytes, Type type)
   at Akka.Serialization.Serialization.Deserialize(Byte[] bytes, Int32 serializerId, String manifest)
   at Akka.Remote.DefaultMessageDispatcher.Dispatch(IInternalActorRef recipient, Address recipientAddress, Payload message, IActorRef senderOption)
   at Akka.Remote.EndpointReader.<Reading>b__11_1(InboundPayload inbound)
   at lambda_method(Closure , Object , Action`1 , Action`1 , Action`1 )
   at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, PartialAction`1 partialAction)
   at Akka.Actor.UntypedActor.Receive(Object message)
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
   at Akka.Actor.ActorCell.ReceiveMessage(Object message)
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)]
Cause: Unknown

The issue here is that we're using JSON.NET at all for this - this should be in a protobuf message.

@Aaronontheweb
Copy link
Member Author

Looks like we're missing a protobuf message definition for this inside the JVM project:

https://github.com/akka/akka/blob/4e52432706f0460c477142ce185ec8b2c4b5dec8/akka-cluster-sharding/src/main/protobuf/ClusterShardingMessages.proto#L56-L63

I had figured as much - I'll go and add this.

@Aaronontheweb
Copy link
Member Author

Looks like the issue is actually ClusterShardingStats causing this serialization error - although we don't properly serialize ShardRegionStats either using protobuf. I'll add a proto definition for ClusterShardingStats too.

@Aaronontheweb
Copy link
Member Author

public sealed class GetClusterShardingStats : IShardRegionQuery
{
/// <summary>
/// TBD
/// </summary>
public readonly TimeSpan Timeout;
/// <summary>
/// TBD
/// </summary>
/// <param name="timeout">TBD</param>
public GetClusterShardingStats(TimeSpan timeout)
{
Timeout = timeout;
}
}
/// <summary>
/// Reply to <see cref="GetClusterShardingStats"/>, contains statistics about all the sharding regions in the cluster.
/// </summary>
[Serializable]
public sealed class ClusterShardingStats
{
/// <summary>
/// TBD
/// </summary>
public readonly IImmutableDictionary<Address, ShardRegionStats> Regions;
/// <summary>
/// TBD
/// </summary>
/// <param name="regions">TBD</param>
public ClusterShardingStats(IImmutableDictionary<Address, ShardRegionStats> regions)
{
Regions = regions;
}
}
- barfs when we attempt to deserialize the Address using JSON.NET.

Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this issue Jun 26, 2019
Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this issue Jun 26, 2019
madmonkey pushed a commit to madmonkey/akka.net that referenced this issue Jul 12, 2019
* close akkadotnet#3830 - added serialization support for ClusterShardingStats
Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this issue Jul 21, 2019
* close akkadotnet#3830 - added serialization support for ClusterShardingStats
Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this issue Jul 26, 2019
* close akkadotnet#3830 - added serialization support for ClusterShardingStats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant