microsoft/PowerPlatform-DataverseServiceClient

_isCloning is not thread-safe in `SetClonedProperties`

clongfei opened this issue · 2 comments

I encountered an issue when I executed the Clone() function to clone a ServiceClient object. The getting OrganizationDetail action, which is supposed to be triggered during this process, inconsistently sends a request to Dataverse. I suspect this may be due to the _isCloning variable not being thread-safe. Based on my understanding, it shouldn't be necessary to send a request to Dataverse during a cloning operation.

image

@clongfei

Thanks for your report here.
For this to trip up, it would mean that your trying to call clone from multiple threads concurrently.
We will get this fixed. However we strongly recommend you do not use clone here and instead use the Async versions of the calls to dataverse.

However we strongly recommend you do not use clone here and instead use the Async versions of the calls to dataverse.

I think you should try to somehow make it more clear that .Clone() should only be used with .Net Framework and not with .Net Core when doing high workload.

When converting some old code to .Net Core we ran into a very high port usage, we traced it down to probably be related to our usage of clones (every call would use its own clone). After removing clones the issue seems to be resolved (waiting confirmation in production)

My guess (without having gone into details) is that the clones dont share their httpclients (it might be related to "require unique instances" being set to true on the serviceclient).