spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Refresh endpoint makes the HikariDataSource as shutdown

Open max-macalupu opened this issue 7 years ago • 17 comments

As part of migration of spring-boot 1.5.9 to 2.1.4.RELEASE, I have an existent custom DataSource using the DataSourceBuilder.java and the @ConfigurationProperties annotation:

 @Bean
  @ConfigurationProperties(prefix = "web.datasource")
  public DataSource getDataSource() {
    return DataSourceBuilder.create().build();
  }

Issue: The custom datasource is shutdown when the Refresh endpoint is call and after a query database hit. Spring cloud dependencies: Greenwich.SR1 Spring boot: 2.1.4.RELEASE

application.properties

web.datasource.password=
web.datasource.userName=sa
web.datasource.jdbcUrl=jdbc:h2:mem:testdb
web.datasource.driverClassName=org.h2.Driver
web.datasource.type=HikariDataSource

spring.cloud.refresh.extra-refreshable=javax.sql.DataSource

Refresh endpoint exception:

2019-06-10 11:27:48.407  INFO 18530 --- [nio-9000-exec-2] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$b0795841] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-06-10 11:27:48.608  INFO 18530 --- [nio-9000-exec-2] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2019-06-10 11:27:48.635  INFO 18530 --- [nio-9000-exec-2] o.s.boot.SpringApplication               : Started application in 0.449 seconds (JVM running for 17.377)
2019-06-10 11:27:49.087  INFO 18530 --- [nio-9000-exec-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2019-06-10 11:27:49.115  INFO 18530 --- [nio-9000-exec-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

For more details I created this project that recreate the issue: https://github.com/max-macalupu/CloudRefreshIssue

max-macalupu avatar Jun 10 '19 17:06 max-macalupu

We have the same issue, only without actually calling the refesh endpoint. If any property in consul is changed, the refresh causes all active database connections to be killed, causing failures in our services. If it's a global property, every service is affected. Setting the spring.cloud.refresh.refreshable property doesn't help because the RefreshScopeBeanDefinitionEnhancer is invoked before the property gets set (and the setRefreshable method is called on the RefreshScopeBeanDefinitionEnhancer), and since the bean definition has been modified to be refreshed, the damage is done.

gwcary avatar Jun 21 '19 14:06 gwcary

Hi @gwcary, thanks for following up. I founded a workaround using the ignoreInvalidFields = true attribute, that stop the datasource shutdown.

 @Bean
  @ConfigurationProperties(prefix = "web.datasource", ignoreInvalidFields = true)
  public DataSource getDataSource() {
    return DataSourceBuilder.create().build();
  }

max-macalupu avatar Jun 25 '19 03:06 max-macalupu

Hello @max-macalupu Which Spring Cloud version are you using exactly (we don't have Greenwich.SR5)? Please provide a minimal, complete, verifiable example that reproduces the issue.

OlgaMaciaszek avatar Jul 29 '19 14:07 OlgaMaciaszek

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Aug 05 '19 14:08 spring-projects-issues

Hi @OlgaMaciaszek, Thanks for following up. The Spring Cloud version is <version>Greenwich.SR1</version> (I already updated the issue description). Also this is the minimal example that reproduces the issue: https://github.com/max-macalupu/CloudRefreshIssue

max-macalupu avatar Aug 05 '19 15:08 max-macalupu

Please try again with Greenwich.SR2 and boot 2.1.6 to see if it's still an issue

spencergibb avatar Aug 05 '19 15:08 spencergibb

Hi @spencergibb issue still exist in sboot 2.1.6.RELEASE with Greenwinch.SR2.

max-macalupu avatar Aug 05 '19 17:08 max-macalupu

Thanks for checking

spencergibb avatar Aug 05 '19 17:08 spencergibb

I am using springBootVersion = '2.1.3.RELEASE'. I am trying to use /actuator/refresh but as soon as I POST to this url, the HikariPool shutsdown

2019-09-03 10:48:04 INFO  o.s.s.c.ThreadPoolTaskExecutor - Shutting down ExecutorService 'applicationTaskExecutor'
2019-09-03 10:48:04 INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2019-09-03 10:48:04 INFO  o.h.t.s.i.SchemaDropperImpl$DelayedDropActionImpl - HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2019-09-03 10:48:04 INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2019-09-03 10:48:04 INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.

Is there a solution for this?

ksavakia avatar Sep 03 '19 19:09 ksavakia

I have the same issue with 2.2.1.RELEASE, Hoxton.RC1. As soon as I POST to the "/actuator/refresh" endpoint it shuts down the Hikari Pool.

deevodavis71 avatar Nov 11 '19 17:11 deevodavis71

Switching back to Tomcat Datasource seemed the best way to deal with this problem for now.

biergit avatar Jan 09 '20 08:01 biergit

When #318 was done HikariDataSource beans could be refreshed, but with changes to Hikari this solution no longer works.

Using the project https://github.com/spring-cloud/spring-cloud-commons/issues/571#issuecomment-518287610 I don't get any errors on refresh, but when next accessed there is a NPE.

org.h2.jdbc.JdbcSQLException: Table "GREETING" not found; SQL statement:
SELECT id, content FROM GREETING LIMIT 1 [42102-197]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
	at org.h2.message.DbException.get(DbException.java:179)
	at org.h2.message.DbException.get(DbException.java:155)
	at org.h2.command.Parser.readTableOrView(Parser.java:5920)
	at org.h2.command.Parser.readTableFilter(Parser.java:1430)
	at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:2138)
	at org.h2.command.Parser.parseSelectSimple(Parser.java:2287)
	at org.h2.command.Parser.parseSelectSub(Parser.java:2133)
	at org.h2.command.Parser.parseSelectUnion(Parser.java:1946)
	at org.h2.command.Parser.parseSelect(Parser.java:1919)
	at org.h2.command.Parser.parsePrepared(Parser.java:463)
	at org.h2.command.Parser.parse(Parser.java:335)
	at org.h2.command.Parser.parse(Parser.java:307)
	at org.h2.command.Parser.prepareCommand(Parser.java:278)
	at org.h2.engine.Session.prepareLocal(Session.java:611)
	at org.h2.engine.Session.prepareCommand(Session.java:549)
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
	at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78)
	at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111)
	at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
	at com.springcloud.refresh.issue.GreetingDao.getGreeting(GreetingDao.java:29)
	at com.springcloud.refresh.issue.GreetingController.sayHello(GreetingController.java:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

java.lang.NullPointerException: null
	at com.springcloud.refresh.issue.GreetingDao.getGreeting(GreetingDao.java:41) ~[classes/:na]
	at com.springcloud.refresh.issue.GreetingController.sayHello(GreetingController.java:17) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109) ~[spring-boot-actuator-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.31.jar:9.0.31]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]

I think we should exclude HikariDataSource from any refreshing and if users want a refreshable datasource, use tomcat.

spencergibb avatar Mar 03 '20 22:03 spencergibb

Closed via 69a8cece5fd35480d549948cabe3006562eab896 i messed up fixes line in commit messages

spencergibb avatar Mar 03 '20 22:03 spencergibb

@spencergibb We had been running with this version of Spring Boot and Spring Cloud prior to upgrading to Spring Boot 2.2.6, Spring Cloud Hoxton.SR3, and had no problems with the refresh functionality.

I believe this issue may be related to the in-memory h2 database, not Hikari.

I have run the example from OP, but pointing to a local MySQL database instead, and everything worked fine.

Logs from POST /actuator/refresh and GET /greeting:

2020-06-12 12:12:14.372  INFO 719404 --- [nio-9001-exec-7] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$aa9f4699] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-06-12 12:12:18.785  INFO 719404 --- [nio-9001-exec-7] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2020-06-12 12:12:18.796  INFO 719404 --- [nio-9001-exec-7] o.s.boot.SpringApplication               : Started application in 8.665 seconds (JVM running for 120.707)
2020-06-12 12:12:18.962  INFO 719404 --- [nio-9001-exec-7] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown initiated...
2020-06-12 12:12:18.977  INFO 719404 --- [nio-9001-exec-7] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown completed.
2020-06-12 12:12:27.981  INFO 719404 --- [io-9001-exec-10] com.zaxxer.hikari.HikariDataSource       : HikariPool-3 - Starting...
2020-06-12 12:12:27.988  INFO 719404 --- [io-9001-exec-10] com.zaxxer.hikari.HikariDataSource       : HikariPool-3 - Start completed.

I also tried switching the example project over to the Tomcat datasource (sticking with H2), and met with the same error as with Hikari. This is with the original Spring versions in the example project, and also with Spring Boot 2.2.6, Spring Cloud Hoxton.SR3.

So, it seems to me that making HikariDataSource non-refreshable is the wrong fix; rather, you should make DataSources nonrefreshable when using the in-memory h2 database. The current fix loses some useful functionality (e.g. rotating database credentials at runtime) :(.

pmahony893 avatar Jun 12 '20 11:06 pmahony893

@spencergibb I switched h2 to mysql with the example above, then I found that hikari can work normally.

doupeng19940218 avatar Feb 20 '24 09:02 doupeng19940218

@spencergibb Please consider this: event.getKeys() knows which keys changed (my-properties.pro1), then should search ConfigurationPropertiesBean which "my-properties.pro1" started with ConfigurationProperties#prefix() , if matches, the ConfigurationPropertiesBean object sholud be rebind, not all beans.

mengyongfeng avatar May 27 '24 09:05 mengyongfeng

Please consider this: event.getKeys() knows which keys changed (my-properties.pro1), then should search ConfigurationPropertiesBean which "my-properties.pro1" started with ConfigurationProperties#prefix() , if matches, the ConfigurationPropertiesBean object sholud be rebind, not all beans.

@mengyongfeng It's possible that custom BeanPostProcessor bind other prefix in addition to ConfigurationProperties#prefix(), Spring Cloud cannot know which beans is affected by prefix in such condition.

quaff avatar Feb 05 '25 09:02 quaff