Skip to content

Fix duplicate query counting when a DataSource bean delegates to another DataSource bean - #264

Open
jjh75607 wants to merge 1 commit into
quick-perf:masterfrom
jjh75607:fix/duplicate-count-delegating-datasource
Open

Fix duplicate query counting when a DataSource bean delegates to another DataSource bean#264
jjh75607 wants to merge 1 commit into
quick-perf:masterfrom
jjh75607:fix/duplicate-count-delegating-datasource

Conversation

@jjh75607

@jjh75607 jjh75607 commented Aug 17, 2026

Copy link
Copy Markdown

Hi @jeanbisutti

QuickPerfProxyBeanPostProcessor now marks every proxy it builds with
QuickPerfProxiedDataSource, and walks the delegation chain before wrapping so a DataSource
that already carries the mark is skipped. The delegate is reached by reflection, since
spring-jdbc isn't a dependency of these modules.

That's ~30 lines, applied to both sql-spring4 and sql-spring5. Tests for the delegating
and non-delegating cases go into the Spring Boot 1, 2 and 3 test modules.

Fixes #263

One risk that isn't visible in the diff: LazyConnectionDataSourceProxy also holds a
readOnlyDataSource, which getTargetDataSource doesn't reach. If it's set to a DataSource
that isn't itself a bean, read-only queries go from counted once to not counted at all.

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.

Queries are counted twice when a DataSource bean delegates to another DataSource bean

1 participant