Skip to content

Fix "System.Runtime.Remoting.RemotingException: Object /<identifier1>/<identifier2>.rem has been disconnected or does not exist at the server."#822

Merged
zacharycmontoya merged 3 commits into
masterfrom
zach/fix/scope-storage-appdomain-lease
Aug 11, 2020
Merged

Fix "System.Runtime.Remoting.RemotingException: Object /<identifier1>/<identifier2>.rem has been disconnected or does not exist at the server."#822
zacharycmontoya merged 3 commits into
masterfrom
zach/fix/scope-storage-appdomain-lease

Conversation

@zacharycmontoya

Copy link
Copy Markdown
Contributor

When building Datadog.Trace for net45, we simulate AsyncLocal storage (needed for correct scope management) by storing the current Scope in the Logical Call Context. This uses the remoting infrastructure which sets default leases on objects stored in the Logical Call Context. If execution happens in another AppDomain and the lease expires, we get the above exception.

This PR follows the solution laid out by Serilog when they previously encountered this error. See issue serilog/serilog#987 and the corresponding fix serilog/serilog#992. When adding objects to the Logical Call Context, add logic so they always have an object claiming a lease on them from the host AppDomain so they never get removed from the "remote client" (Logical Call Context).

@DataDog/apm-dotnet

…>/<identifier2>.rem' has been disconnected or does not exist at the server."

When building Datadog.Trace for net45, we simulate AsyncLocal storage (needed for correct scope management) by storing the current Scope in the Logical Call Context. This uses the remoting infrastructure which sets default leases on objects stored in the Logical Call Context. If execution happens in another AppDomain and the lease expires, we get the above exception.

This PR

See issue serilog/serilog#987 and the corresponding fix serilog/serilog#992
@zacharycmontoya
zacharycmontoya requested a review from a team as a code owner July 28, 2020 02:17
@zacharycmontoya zacharycmontoya self-assigned this Jul 28, 2020
@macrogreg

Copy link
Copy Markdown
Contributor

Thanks for the PR.
Interestingly, NetFx does not have this:
https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.Current.net45.cs

Do you know why they are not suffering from this problem? Perhaps we should file an issue so that they can consider also applying a similar change?

Comment thread src/Datadog.Trace/DisposableObjectHandle.cs Outdated
Comment thread test/Datadog.Trace.Tests/TracerTests.cs
@zacharycmontoya
zacharycmontoya merged commit 2081eaa into master Aug 11, 2020
@zacharycmontoya
zacharycmontoya deleted the zach/fix/scope-storage-appdomain-lease branch August 11, 2020 23:17
@zacharycmontoya zacharycmontoya added this to the 1.19.2 milestone Aug 31, 2020
@zacharycmontoya zacharycmontoya added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants