Skip to content

DB statement sanitization causes memory leaks #13180

@railsharipov

Description

@railsharipov

Describe the bug

DB statement sanitization is enabled by default: https://opentelemetry.io/docs/zero-code/java/agent/instrumentation/#db-statement-sanitization

I was debugging memory leak for an application that dynamically builds large SQL query strings and frequently executes them using JDBC. I saw a lot of humongous live objects accumulating in heap space. After analyzing a heap dump I saw that the root cause is in a sqlToStatementInfoCache field in a io.opentelemetry.javaagent.shaded.instrumentation.api.incubator.semconv.db.SqlStatementSanitizer class.

Image Image

Please let me know what additional information I can provide to help diagnose this issue.

Steps to reproduce

An application that dynamically builds large SQL query strings and frequently executes them using JDBC.

Expected behavior

Memory usage returns to baseline when application is idling.

Actual behavior

Baseline memory usage increases after application runs jobs involving a lot of large SQL query executions.

Javaagent or library instrumentation version

2.11.0

Environment

JDK: Amazon Coretto 17
OS: Alpine 3.18

Additional context

While investigating I ran application with different garbage collectors. Disabling DB statement sanitization resolved the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions