Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disposing a disposed object #4843

Open
RichardChen820 opened this issue Oct 23, 2024 · 2 comments
Open

Disposing a disposed object #4843

RichardChen820 opened this issue Oct 23, 2024 · 2 comments
Assignees
Labels
customer-reported Issue created by a customer good first issue Good for newcomers needs-investigation

Comments

@RichardChen820
Copy link

RichardChen820 commented Oct 23, 2024

Describe the bug
My application is running in Kubernetes, when I do deployment the old pod raised following exception when it shuts down. In my code, it just call CosmosClinet.Dispose() in object Dispose method.

Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Channel'.
at Microsoft.Azure.Documents.Rntbd.Channel.System.IDisposable.Dispose()
at Microsoft.Azure.Documents.Rntbd.LbChannelState.Dispose()
at Microsoft.Azure.Documents.Rntbd.LoadBalancingPartition.Dispose()
at Microsoft.Azure.Documents.Rntbd.LoadBalancingChannel.System.IDisposable.Dispose()
at Microsoft.Azure.Documents.Rntbd.LoadBalancingChannel.Close()
at Microsoft.Azure.Documents.Rntbd.ChannelDictionary.Dispose()
at Microsoft.Azure.Documents.Rntbd.TransportClient.Dispose()
at Microsoft.Azure.Documents.StoreClientFactory.Dispose()
at Microsoft.Azure.Cosmos.DocumentClient.Dispose()
at Microsoft.Azure.Cosmos.ClientContextCore.Dispose(Boolean disposing)
at Microsoft.Azure.Cosmos.ClientContextCore.Dispose()
at Microsoft.Azure.Cosmos.CosmosClient.Dispose(Boolean disposing)
at Microsoft.Azure.Cosmos.CosmosClient.Dispose()
at Microsoft.AppConfig.Agent.Storage.CosmosDbStorage.Dispose() in C:\__w\1\s\src\Microsoft.AppConfig.Agent.Storage\CosmosDbStorage.cs:line 47
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.DisposeAsync()
--- End of stack trace from previous location ---
at Microsoft.Extensions.Hosting.Internal.Host.DisposeAsync()
at Microsoft.Extensions.Hosting.Internal.Host.Dispose()
at Microsoft.AppConfig.Agent.Program.Main(String[] args) in C:\__w\1\s\src\Microsoft.AppConfig.Agent\Program.cs:line 35
at Microsoft.AppConfig.Agent.Program.<Main>(String[] args)

Environment summary
SDK Version: 3.43.0
OS Version: linux

@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issue created by a customer label Oct 23, 2024
@kirankumarkolli kirankumarkolli added the good first issue Good for newcomers label Oct 29, 2024
@ananth7592 ananth7592 self-assigned this Oct 30, 2024
@ananth7592
Copy link

Hi @RichardChen820 , I would appreciate some clarification on a few points to help me understand the issue better:

  • Is the CosmosClient being utilized as a singleton instance throughout the application lifecycle within the pod?
  • Does this exception occur every time a K8s deployment is performed, during the shutdown of the pod?
  • Is this a regular deployment? If possible, could you please provide the repro steps to help me replicate the issue?

@RichardChen820
Copy link
Author

@ananth7592 Thanks for helping look into this
Is the CosmosClient being utilized as a singleton instance throughout the application lifecycle within the pod?

Yes, CosmosClient is used as a singleton in my app.

Does this exception occur every time a K8s deployment is performed, during the shutdown of the pod?

No, it only happened once, I haven't seen it again after the last occurrence.

Is this a regular deployment? If possible, could you please provide the repro steps to help me replicate the issue?

This is a regular deployment that is performed nearly every two weeks. As of now we can't reproduce it as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issue created by a customer good first issue Good for newcomers needs-investigation
Projects
None yet
Development

No branches or pull requests

3 participants