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

DB statement sanitization causes memory leaks #13180

Open
railsharipov opened this issue Feb 3, 2025 · 2 comments
Open

DB statement sanitization causes memory leaks #13180

railsharipov opened this issue Feb 3, 2025 · 2 comments
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@railsharipov
Copy link

railsharipov commented Feb 3, 2025

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.

@railsharipov railsharipov added bug Something isn't working needs triage New issue that requires triage labels Feb 3, 2025
@laurit
Copy link
Contributor

laurit commented Feb 5, 2025

How large are these sql statements? Multiple megabytes?

@railsharipov
Copy link
Author

How large are these sql statements? Multiple megabytes?

Quite large, I see statements with sizes to up to 15MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

2 participants