Azure / durabletask

Durable Task Framework allows users to write long running persistent workflows in C# using the async/await capabilities.
Apache License 2.0
1.53k stars 296 forks source link

Changes in the version 2.14.0 break DurableTask.AzureServiceFabric #967

Closed dsempi closed 1 year ago

dsempi commented 1 year ago

If upgrading to the latest DurableTask.Core (2.14.0) when using DurableTask.AzureServiceFabric, you get the following error:

System.Runtime.Serialization.InvalidDataContractException: Type 'DurableTask.Core.Tracing.DistributedTraceContext' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.
   at System.Runtime.Serialization.XmlObjectSerializerContext.CheckIfTypeSerializable(Type memberType, Boolean isMemberTypeSerializable)
   at WriteExecutionStartedEventToXml(XmlWriterDelegator, Object, XmlObjectSerializerWriteContext, ClassDataContract)
   at System.Runtime.Serialization.DataContracts.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteTaskMessageToXml(XmlWriterDelegator, Object, XmlObjectSerializerWriteContext, ClassDataContract)
   at System.Runtime.Serialization.DataContracts.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteTaskMessageItemToXml(XmlWriterDelegator, Object, XmlObjectSerializerWriteContext, ClassDataContract)
   at System.Runtime.Serialization.DataContracts.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at Microsoft.ServiceFabric.Replicator.DataContractStateSerializer`1.Write(T value, BinaryWriter binaryWriter)
   at Microsoft.ServiceFabric.Replicator.DataContractStateSerializer`1.Write(T currentValue, T newValue, BinaryWriter binaryWriter)
   at System.Fabric.Store.TStore`5.GetValueBytes(TValue currentValue, TValue newValue)
   at System.Fabric.Store.TStore`5.TryAddAsync(IStoreWriteTransaction transaction, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken)
   at DurableTask.AzureServiceFabric.Stores.SessionProvider.TryAddSession(ITransaction transaction, TaskMessageItem newMessage)
   at DurableTask.AzureServiceFabric.FabricOrchestrationServiceClient.<>c__DisplayClass4_0.<<CreateTaskOrchestrationAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at DurableTask.AzureServiceFabric.TaskHelpers.RetryHelper.ExecuteWithRetryOnTransient[TResult](Func`1 action, IRetryPolicy retryPolicy, String uniqueActionIdentifier)
   at DurableTask.AzureServiceFabric.TaskHelpers.RetryHelper.ExecuteWithRetryOnTransient[TResult](Func`1 action, IRetryPolicy retryPolicy, String uniqueActionIdentifier)
   at DurableTask.AzureServiceFabric.FabricOrchestrationServiceClient.CreateTaskOrchestrationAsync(TaskMessage creationMessage)
   at DurableTask.Core.TaskHubClient.InternalCreateOrchestrationInstanceWithRaisedEventAsync(String orchestrationName, String orchestrationVersion, String orchestrationInstanceId, Object orchestrationInput, IDictionary`2 orchestrationTags, OrchestrationStatus[] dedupeStatuses, String eventName, Object eventData, Nullable`1 startAt) in /_/src/DurableTask.Core/TaskHubClient.cs:line 619

This issue is pretty similar to #819, just this time it seems the newly added class DistributedTraceContext is missing the DataContract attribute.

davidmrdavid commented 1 year ago

@bachuv just FYI

dsempi commented 1 year ago

It seems to be fixed in version 2.15.1.