Skip to content

Conversation

@jansimonb
Copy link
Contributor

@jansimonb jansimonb commented Nov 19, 2025

Proposed Changes

  • Fixed Arrow memory leak when a query thread is interrupted during stream consumption
    • Retry flightStream.close() on failure: First attempt drains the stream but throws exception; retry completes
      cleanup successfully
    • Always close Arrow resources, even if FlightStream close fails
  • Added MemoryLeakIssueTest E2E test that reproduces the bug via thread interruption
  • No breaking changes, backwards compatible

Background

The problem was that when a query thread is interrupted during stream consumption, FlightStream.close() throws
InterruptedException which bypasses cleanup code, leaving Apache Arrow buffers unreleased. This caused memory leaks
(exception "Memory was leaked by query. Memory leaked").

The root cause is that FlightStream.close() only catches FlightRuntimeException, not InterruptedException. When
interrupted, the exception escapes before the cleanup block executes, leaking Arrow buffers.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.83%. Comparing base (ddb8948) to head (454802b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...m/influxdb/v3/client/internal/FlightSqlClient.java 52.94% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
- Coverage   87.22%   86.83%   -0.40%     
==========================================
  Files          20       20              
  Lines        1284     1299      +15     
  Branches      213      215       +2     
==========================================
+ Hits         1120     1128       +8     
- Misses         75       81       +6     
- Partials       89       90       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@bednar bednar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with https://github.com/bednar/influxdb3-java-spring-retry and everything is ok.

LGTM 🚀

@jansimonb jansimonb marked this pull request as ready for review November 20, 2025 07:22
@jansimonb jansimonb merged commit 7692c3b into main Nov 20, 2025
8 of 10 checks passed
@jansimonb jansimonb deleted the fix/memoryLeakInQueryStreamClose branch November 20, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants