Skip to content

Make sure we close the connection and don't leak it in java sources. #10128

Closed
@tuliren

Description

@tuliren

Summary

  • There seems to be connection leaks in some of the database connector.
  • We should verify this by adding a leak detection in acceptance test, and fix them.

Description

While investigating #9744, I found two phenomena:

  1. When a Redshift table is empty, reading it in a streaming does not seem to ever reach the onClose method of the stream, which is supposed to close the connection and now it is not executed, leaving the connection open.
  2. The StreamingJdbcDatabase may have connection leak. It calls getConnection from the data source, and it is left for the user to close those connection. When the 1) issue happens, the connection won't get closed.

Update

The issue is not from Redshift when the table is empty. It is connection leak. A Java Stream is not automatically closed. The onClose callback won't be triggered unless the Stream is manually closed. Many of the JdbcDatabase methods return a Stream, which needs to be manually closed or put in a try block. It is not always the case currently, resulting in connection leaks.

Reference

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions