Skip to content

DataSource initialization does not see the result of wrapping or proxying a DataSource via a BeanPostProcessor #23736

@wilkinsona

Description

@wilkinsona

@joshlong has been experimenting with using Spring Retry to make the auto-configured DataSource retry connection retrieval so that the DB does not have to be up when the app is starting. It doesn't work when also trying to initialise the data source with a schema.sql script.

The problem is that the retry proxy that is created in the BPP isn't seen by the data source initializer that's triggered by another BPP. The initializer retrieves the DataSource via an ObjectProvider which, because bean post-processing hasn't completed, cannot see the retry proxy created earlier in the post-processing.

https://github.com/bootiful-kubernetes/retryable-app-and-a-database/tree/b5dbcf9a3d32d0a8d40c0d54728ea97eb6ac9ddb reproduces the problem.

This is related to #9528, #13042 and the like. I doubt it'll be easy to fix. In the meantime using Flyway or Liquibase for initialization is recommended.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions