EventStore / EventStoreDB-Client-Dotnet-Legacy

1 stars 9 forks source link

JSON deserialization error with DiscoverLeader enum value when connecting via GossipSeeds #22

Closed megakid closed 3 years ago

megakid commented 3 years ago

Describe the bug Client library spits out JSON deserialization error when nodes are in DiscoverLeader state.

To Reproduce Steps to reproduce the behavior:

  1. Launch client using a gossip seed connection string
  2. Launch 3 or 5 node cluster
  3. See that there's an interim state whilst the cluster is establishing quorum that causes the client to emit errors

Expected behavior No errors to occur

Actual behavior Client spits out errors - eventually reconnects successfully once cluster quorum is established.

Config/Logs/Screenshots

Failed to get cluster info from ["Unspecified/REDACTED"]: deserialization error: "Newtonsoft.Json.JsonSerializationException: Error converting value \"DiscoverLeader\" to type 'EventStore.ClientAPI.Messages.ClusterMessages+VNodeState'. Path 'members[0].state', line 6, position 31.
 ---> System.ArgumentException: Requested value 'DiscoverLeader' was not found.
   at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)
   at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, 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.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, 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.CreateValueInternal(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 Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at EventStore.ClientAPI.Internal.ClusterDnsEndPointDiscoverer.<>c__DisplayClass16_0.<TryGetGossipFrom>b__0(HttpResponse response)".

EventStore details

Additional context Add any other context about the problem here.

megakid commented 3 years ago

This is caused by:

https://github.com/EventStore/EventStoreDB-Client-Dotnet-Legacy/blob/661438208d2848e497f16aeb1203bcf198ac1d6a/src/EventStore.ClientAPI/Messages/ClusterMessages.cs#L74-L92

not containing DiscoverLeader enum value.

I assume this should match the EventStore.Core enum values here:

https://github.com/EventStore/EventStore/blob/3684a8ed66c968df2b090241b3be602a20c102a6/src/EventStore.Core/Data/VNodeState.cs#L3-L20