oracle / oci-typescript-sdk

Oracle Cloud Infrastructure SDK for TypeScript and JavaScript
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdk.htm
Other
71 stars 51 forks source link

Missed call to circuitBreaker.shutdown() #244

Closed bohdand-weka closed 7 months ago

bohdand-weka commented 10 months ago

In our project we've found high CPU usage from OCI SDK.

After investigation we've found that reason is circuitbreaker. By disabling it CPU usage was ok.

In our codebase we're using object-storage-client, like this:

func getClient() {
   return new ObjectStorageClient({authenticationDetailsProvider: provider})
}

So for many requests we're having many client instances with circuitbreaker for each. Circuitbreaker has timers which has to be cleaned up after ObjectStorageClient is not in use by calling _circuitBreaker.shutdown().

So we need ObjectStorageClient.shutdown() method to be implemented as well

jyotisaini commented 10 months ago

@bohdand-weka Thanks for reporting the issue. Circuit breaker timers are reset once the circuit breaker is close. Are you saying for each client the circuit breaker remains open leading to high CPU usage ?

bohdand-weka commented 10 months ago

@jyotisaini it looks like so, we're working on fixing the issue on our side - even the client gets GC'ed - timers aren't going to reset

jyotisaini commented 9 months ago

Let us know if it works once you fix issue at your end and if you need further assistance.

JoshuaWR commented 9 months ago

Hi @bohdand-weka, I wanted to check in again and ask if you have fixed the issue, or if you have learned anything else about it from your end. Thank you!

bohdand-weka commented 9 months ago

@JoshuaWR we've have to apply the patch to ObjectStorageClient to call shutdown manually, so it fixed the issue for us

JoshuaWR commented 9 months ago

Thanks for the update @bohdand-weka. If you don't mind, could you share the code snippet you used to patch this issue? Was it just a change to ObjectStorageClient or did you also need to change how you were using it in your own code?

bohdand-weka commented 8 months ago

I has to expose _circuitBreaker and call it's shutdown() method when ObjectStorageClient is not needed, but for you I guess you'll better to implement shutdown() method on your own and update doc that users must to call it for cleanup

JoshuaWR commented 7 months ago

Hi again @bohdand-weka, please refer to the latest release of the SDK, which now includes a method in each client which allows the user to shut down the circuit breaker once it is no longer needed. An example of this method can be found here. Please let us know if this fixes the issue you were facing, thank you!

bohdand-weka commented 7 months ago

@JoshuaWR looks cool, we will try it in near future, thanks!

JoshuaWR commented 7 months ago

@bohdand-weka Have you had a chance to try this change out yet? Can I close this ticket for you? Thanks!

bohdand-weka commented 7 months ago

@JoshuaWR I'm pretty sure we can close the ticket, everything looks good!