microsoft/GraphEngine

Global.CloudStorage.SaveStorage() throw Serialization Exception

sunkararp opened this issue · 21 comments

Hi Grapheengine team,

I’m getting Serialization Exception when I call Global.CloudStorage.SaveStorage() methid,
Any Idea how to fix this?

System.Runtime.Serialization.SerializationException
HResult=0x8013150C
Message=Type 'System.ValueTuple2[[Trinity.DynamicCluster.Storage.ReplicaInformation, Trinity.DynamicCluster, Version=2.0.10792.0, Culture=neutral, PublicKeyToken=null],[Trinity.DynamicCluster.PersistedSlice, Trinity.DynamicCluster, Version=2.0.10792.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' is not marked as serializable. Source=mscorlib StackTrace: at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at Trinity.DynamicCluster.Utils.Serialize[T](T payload) in C:\Research\GraphEngine\src\Modules\GraphEngine.DynamicCluster\Trinity.DynamicCluster\Utils.cs:line 162
at Trinity.ServiceFabric.Infrastructure.Interfaces.ReliableTaskQueue.<>c__DisplayClass13_0.<b__0>d.MoveNext()

This exception was originally thrown at this call stack:
[External Code]
Trinity.DynamicCluster.Utils.Serialize(T) in Utils.cs
[External Code]

@sunkararp please post the offending code here so that I can assist your further.

My code is very simple, Service Fabric satefull remoting service & client
My code is here https://github.com/sunkararp/Ayushman.KgApplication.

Exception is happening when client calls Global.CloudStorage.SaveStorage() method at ln@231 of file https://github.com/sunkararp/Ayushman.KgApplication/blob/main/Ayushamn.KgClient/GraphEngineRemotingClient.cs

the client, calls protocol methods before calling Global.CloudStorage.SaveStorage()
the service, protocol me saves the data Global.LocalStorage.SaveStorage

@sunkararp you've done too much unnecessary work here. Firstly, you must use the graph data model generated via TSL; I do not see any TSL in your project. The Graph Engine TSL compiler will generate especially generated typed C# files for you. This is one of the very powerful aspects of the Graph Engine; the graph data model is codegen for you. You willl need to use those generated classes. It does not seem like you've read the documentation - you must do that and take a look at the Sample Graph Service Fabric project.

On server side, I'm using TSL generated code to write memory (like Global.LocalStorage.SavePatientNode(cell))
Please see my code https://github.com/sunkararp/Ayushman.KgApplication/tree/main/Ayushman.KgProtocols

@sunkararp Yikes - I did not see that - my bad. Are you using those same generated files in your remoting client?

Yes, client does following...

  • Create TSL generated object
  • Set all the properties
  • Call the protocol method

` var organization = new OrganizationT();
organization.Id = o.Id;
organization.Name = o.NAME;
organization.Revenue = o.REVENUE;
organization.Phone = o.PHONE;
organization.Utilization = o.UTILIZATION;

            using var cell = new AddOrganizationRequestWriter(organization);
            using var res2 = m_trinity.AddOrganization(cell);`

@sunkararp Just a moment - I am testing your project.

@sunkararp Just a moment - you are running a back release of the Graph Engine Library.

I didn't understand your question.
Below is what I did...

  • I cloned GraphEngine repo
  • Compiled locally, Windows10 & VS2019
  • In my application, used the locally generated Nugets

@sunkararp no worries - I have made many updates to my local repro and so my local build is ahead of yours. I just need to get to one of my dev machines with that build on it.

Just uploaded Data files here

@sunkararp I'll have the fix for you shortly after I get other production matters resolved.

@sunkararp I'm working on your code now and I will have an update for you shortly.

@sunkararp found the problem! I'm updating your project with corrections. I'll come back here when I the VS solution ready.

Thank you so much for the help,
can you share your email ID, I have few more questions.
My email ID is porscheme@live.com

Any luck here?

@sunkararp I will post the fix tomorrow. I've been very busy with pushing out a new release.

Any update here?

@sunkararp The current implementation for GE to run in Service Fabric major rework of the runtime must take place. After much review with Microsoft Service Fabric team and an outside third party it has been determined by the current tcp/ip stack is not compatible with SF due to the advanced use of duplex sockets. However, I have reworked the part of the networking stack so that it's compatible with SF. The scheduled release of the build will not be ready until the December / January timeframe. Also as I'm not able to update the Microsoft Graph Engine github repo current at this time and new versions of the GE will appear at my InKnowWorks GraphEngine repo. You can find updated Nuget packages there with support for. Net 3.1,. Net 5 and 6. We are very actively working on the Graph Engine so that an modernized and updated version is available. I'll post an updated Readme file today sighting updates, and schedule availability and road map.

@sunkararp I have been working on the GE/SF implementation in the background and finally have more time to address this problem. I hope to have a fix in place next week.