Skip to content

[BUG] PerCallTimeoutCall causing OOM #42871

@arikogan

Description

@arikogan

Describe the bug
The PR 40017 introduced the class PerCallTimeoutCall.
This class holds a static Timer with strong references to every call it processes.
When uploading a blob in blocks, each block is a call that gets added to the Timer, not released quickly enough and causing the Timer to hold all calls in memory without the garbage collector being able to free them. This causes the system to deplete its memory.

See BlobClient

public Response<BlockBlobItem> uploadWithResponse(BlobParallelUploadOptions options, Duration timeout,
        Context context) {

Exception or Stack Trace
Image

To Reproduce
Set up any project using the Azure Java SDK and upload binaries at moderate pace using the method BlobClient.uploadWithResponse

Code Snippet
See PerCallTimeoutCall

private static final Timer TIMER = new Timer("azure-okhttp-response-timeout-tracker", true);

...

public void beginPerCallTimeout(Call call) {
        if (perCallTimeout > 0) {
            TimerTask currentTimeout = new PerCallTimerTask(this, call);

            TIMER.schedule(currentTimeout, perCallTimeout);
            TimerTask existing = CURRENT_TIMEOUT_UPDATER.getAndSet(this, currentTimeout);
            if (existing != null) {
                existing.cancel();
            }
        }
    }

Expected behavior
The system shouldn't run out of memory.

Screenshots
Image

Setup (please complete the following information):

  • OS: Any
  • IDE: Any
  • Library/Libraries: com.azure:azure-core:1.51.0, com.azure:azure-core-http-okhttp:1.12.2 (the behavior was introduced in com.azure:azure-core-http-okhttp:1.12.0)
  • Java version: 17
  • App Server/Environment: Tomcat
  • Frameworks: Any

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

Azure.Coreazure-coreClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions