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

Avoid eager checkDefaultConnectionProperties call in LazyConnectionDataSourceProxy #29931

Closed
reda-alaoui opened this issue Feb 5, 2023 · 2 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@reda-alaoui
Copy link

Affects: 6.0.2

On afterPropertiesSet, LazyConnectionDataSourceProxy opens a connection to determine defaultAutoCommit and defaultTransactionIsolation. In case of exception, the latter is trapped, leading LazyConnectionDataSourceProxy to determine those properties when the connection is effectively requested by a consumer.

We use TestContainer to test our database interactions. The database startup takes a few seconds. To reduce test startup time, we start the database in a separate thread while the Spring context is initializing. LazyConnectionDataSourceProxy#checkDefaultConnectionProperties is the first consumer that makes the Spring Context initialization wait on the database startup thread.

It would be nice to have an option allowing to disable this eager check.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 5, 2023
@sbrannen sbrannen added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 7, 2023
@sbrannen
Copy link
Member

sbrannen commented Feb 7, 2023

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
@jhoeller jhoeller reopened this Dec 7, 2023
@jhoeller jhoeller removed the status: superseded An issue that has been superseded by another label Dec 7, 2023
@jhoeller jhoeller self-assigned this Dec 7, 2023
@jhoeller jhoeller added this to the 6.1.2 milestone Dec 7, 2023
@jhoeller jhoeller changed the title Add an option to disable LazyConnectionDataSourceProxy eager checkDefaultConnectionProperties call Avoid eager checkDefaultConnectionProperties call in LazyConnectionDataSourceProxy Dec 7, 2023
@jhoeller
Copy link
Contributor

jhoeller commented Dec 7, 2023

We are dropping the eager connection properties check completely, in favor of a late check on the first getConnection() call (but before exposing the Connection proxy, so still exposing consistent behavior for the consumer of the Connection proxy). As a consequence, there is no need for a configuration flag. If a startup-time check should be enforced (which we don't actually recommend these days), the new public checkDefaultConnectionProperties() method can be called. Even better would be to explicitly specify the defaultAutoCommit and defaultTransactionIsolation configuration settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
4 participants