aws / aws/aws-secretsmanager-jdbc

TomEE - leak of AWSSecretsManagerOracleDriver objects

Open
#53 1 comment 0 reactions 0 assignees View on GitHub
triage/needs-investigation
Dominant language
Java
Stars
196
Forks
87
PR merge metrics
No merged PRs in 30d

Description

Hello,

We are using the aws-secretsmanager-jdbc library in conjunction with TomEE and have been observing a leak of AWSSecretsManagerOracleDriver objects.

After adding some traces in the aws-secretsmanager-jdbc code, what we understood is:

1. Each time a connection is created the TomEE framework instantiates a new AWSSecretsManagerOracleDriver object and sets it as the 'driver' attribute of the connection object (line 235 of TomEEDataSourceCreator.java - link here: https://github.com/apache/tomee/blob/master/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java).

2. When instantiated, the AWSSecretsManagerOracleDriver object registers itself in the 'DriverManager' (line 154 of AWSSecretsManagerDriver.java)

3. When the connection is destroyed later, the driver object is apparently not deregistered from the 'DriverManager', so its stays indefinitely, which creates the leak.

We tried to disable the DriverManager registration in the AWSSecretsManagerOracleDriver constructor (just leaving the registration in the static initialization block of AWSSecretsManagerOracleDriver) and the leak has effectively disappeared. But we fear to have misunderstood something fundamental and that this workaround is not correct: we admit not being very familiar with the aforementioned frameworks. Could anyone shed some light?

Contributor guide

Open the contributing guide

Research direction

Start with TomEEDataSourceCreator.java at line 235 and AWSSecretsManagerDriver.java at line 154, then trace how each connection-created driver is registered and whether it is deregistered when the connection is destroyed. Confirm the retention behavior with the TomEE integration and define done as preventing destroyed AWSSecretsManagerOracleDriver objects from remaining registered without relying on the reported constructor workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.